Skip to content

Commit

Permalink
Create consensus.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 6, 2024
1 parent 77093f1 commit 0b0c24f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions blockchain/consensus/consensus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from .pos import ProofOfStake
from .dpos import DelegatedProofOfStake

def create_consensus(consensus_type: str, validators: list, block_time: int = 10):
if consensus_type == "pos":
return ProofOfStake(validators, block_time)
elif consensus_type == "dpos":
return DelegatedProofOfStake(validators, block_time)
else:
raise ValueError("Invalid consensus type")

def run_consensus(consensus):
consensus.run_consensus()

0 comments on commit 0b0c24f

Please sign in to comment.