diff --git a/blockchain.py b/blockchain.py index cb1cb8a..a6c2f65 100644 --- a/blockchain.py +++ b/blockchain.py @@ -18,7 +18,7 @@ class Blockchain: # Create the genesis block self.new_block(previous_hash='1', proof=100) - def register_node(self, address: str) -> None: + def register_node(self, address): """ Add a new node to the list of nodes @@ -28,7 +28,7 @@ class Blockchain: parsed_url = urlparse(address) self.nodes.add(parsed_url.netloc) - def valid_chain(self, chain: List[Dict[str, Any]]) -> bool: + def valid_chain(self, chain): """ Determine if a given blockchain is valid @@ -57,7 +57,7 @@ class Blockchain: return True - def resolve_conflicts(self) -> bool: + def resolve_conflicts(self): """ This is our consensus algorithm, it resolves conflicts by replacing our chain with the longest one in the network. @@ -91,7 +91,7 @@ class Blockchain: return False - def new_block(self, proof: int, previous_hash: Optional[str]) -> Dict[str, Any]: + def new_block(self, proof, previous_hash): """ Create a new Block in the Blockchain @@ -114,7 +114,7 @@ class Blockchain: self.chain.append(block) return block - def new_transaction(self, sender: str, recipient: str, amount: int) -> int: + def new_transaction(self, sender, recipient, amount): """ Creates a new transaction to go into the next mined Block @@ -132,11 +132,11 @@ class Blockchain: return self.last_block['index'] + 1 @property - def last_block(self) -> Dict[str, Any]: + def last_block(self): return self.chain[-1] @staticmethod - def hash(block: Dict[str, Any]) -> str: + def hash(block): """ Creates a SHA-256 hash of a Block @@ -147,7 +147,7 @@ class Blockchain: block_string = json.dumps(block, sort_keys=True).encode() return hashlib.sha256(block_string).hexdigest() - def proof_of_work(self, last_proof: int) -> int: + def proof_of_work(self, last_proof): """ Simple Proof of Work Algorithm: - Find a number p' such that hash(pp') contains leading 4 zeroes, where p is the previous p' @@ -161,7 +161,7 @@ class Blockchain: return proof @staticmethod - def valid_proof(last_proof: int, proof: int) -> bool: + def valid_proof(last_proof, proof): """ Validates the Proof