diff --git a/DIRECTORY.md b/DIRECTORY.md index f0a34a553946..6d8d1e2658f4 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -55,6 +55,7 @@ ## Blockchain * [Diophantine Equation](blockchain/diophantine_equation.py) + * [Proof Of Work](blockchain/proof_of_work.py) ## Boolean Algebra * [And Gate](boolean_algebra/and_gate.py) diff --git a/blockchain/proof_of_work.py b/blockchain/proof_of_work.py new file mode 100644 index 000000000000..7ca4e0554bda --- /dev/null +++ b/blockchain/proof_of_work.py @@ -0,0 +1,18 @@ +from datetime import datetime, timezone +import hashlib + + +class Block: + def __init__(self, index: int, previous_hash: str, data: str, timestamp: str): + self.index = index + self.previous_hash = previous_hash + self.data = data + self.timestamp = timestamp + + def mine_block(self, difficulty: int) -> None: + # Implement mining logic here + pass + + @staticmethod + def create_genesis_block() -> "Block": + return Block(0, "0", "Genesis Block", datetime.now(timezone.utc).isoformat())