consensus_algorithm Enum

#include <tkcrypt/common.hpp>

Namespace: kc

Overview

The consensus_algorithm enum specifies the consensus protocol to use in ledger transactions. These algorithms define how multiple participants reach agreement in distributed consensus protocols.

Since: v3.0

Values

Value Numeric Description

none

0

No consensus algorithm specified

one_phase_commit

1

One-phase commit protocol (Commit only)

two_phase_commit

2

Two-phase commit protocol (Propose/Commit)

three_phase_commit

3

Three-phase commit protocol (Propose/PreCommit/Commit)

Usage

#include <keychain/keychain_headers.hpp>

// Create a three-phase consensus transaction
kc::transaction tx = gateway.create_transaction(
    persona,
    kc::consensus_algorithm::three_phase_commit,
    quorum,
    tags,
    variables
);

// Start a ledger consensus with two-phase commit
kc::transaction ledger_tx = gateway.ledger_start(
    persona,
    kc::consensus_algorithm::two_phase_commit,
    participants,
    tags,
    variables
);

Protocol Details

One-Phase Commit

  • Single commit phase

  • Fastest but least fault-tolerant

  • Suitable for trusted environments

Two-Phase Commit

  • Propose phase followed by commit phase

  • Better fault tolerance than one-phase

  • Standard for most distributed transactions

Three-Phase Commit

  • Propose, pre-commit, then commit phases

  • Highest fault tolerance

  • Suitable for critical consensus operations

See Also