Enum class ConsensusAlgorithm
Package: keychain.constants
Description
Consensus algorithm used in ledger consensus protocols.
This enum defines the various consensus algorithms that can be used in distributed ledger systems to achieve agreement among network participants on the state of the ledger.
Since: v2.0
Enum Class Summary
Enum Constant | Value | Description |
---|---|---|
0 |
No consensus algorithm specified |
|
1 |
One-phase commit (Commit) |
|
2 |
Two-phase commit (Propose/Commit) |
|
3 |
Three-phases commit (Propose/PreCommit/Commit) |
Enum Class Detail
ONE_PHASE_COMMIT
Value: 1
One-phase commit (Commit). This is the simplest consensus protocol where participants directly commit to a transaction without preliminary phases.
Usage Example
from keychain.constants import ConsensusAlgorithm
# Use two-phase commit for moderate fault tolerance
algorithm = ConsensusAlgorithm.TWO_PHASE_COMMIT
print(f"Using consensus algorithm: {algorithm}") # Outputs: 2
# Check if algorithm is initialized
if algorithm != ConsensusAlgorithm.UNINITIALIZED:
print("Consensus algorithm is properly configured")