Skip to content

Commit 00f590b

Browse files
Fix type hints and add doctests for simple blockchain
1 parent c44d753 commit 00f590b

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

blockchain/simple_blockchain.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import hashlib
1313
from time import time
14-
from typing import List, Tuple
1514

1615

1716
class Block:
@@ -57,7 +56,7 @@ def compute_hash(self, nonce: int) -> str:
5756
)
5857
return hashlib.sha256(block_string.encode()).hexdigest()
5958

60-
def mine_block(self, difficulty: int) -> Tuple[int, str]:
59+
def mine_block(self, difficulty: int) -> tuple[int, str]:
6160
"""
6261
Simple Proof-of-Work mining algorithm.
6362
@@ -92,7 +91,7 @@ class Blockchain:
9291

9392
def __init__(self, difficulty: int = 2) -> None:
9493
self.difficulty = difficulty
95-
self.chain: List[Block] = [self.create_genesis_block()]
94+
self.chain: list[Block] = [self.create_genesis_block()]
9695

9796
def create_genesis_block(self) -> Block:
9897
"""

0 commit comments

Comments
 (0)