blockchain.blockchain package¶
Submodules¶
blockchain.blockchain.block module¶
-
class
blockchain.blockchain.block.Block(index: int, data: blockchain.blockchain.data.Data, proof: int, previous_hash: str)[source]¶ Bases:
object-
__bytes__() → bytes[source]¶ Uses the encoded string representation of this
Blockobject asbytesrepresentation.Returns: byterepresentation ofBlockobject.Return type: bytes
-
__eq__(other: object) → bool[source]¶ Method for comparing two
Blockobjects.Parameters: other (Block) – Blockobject to compare withself.Returns: Trueif blocks are equal.Falseotherwise.Return type: bool
-
__repr__() → str[source]¶ String representation of
Blockobject.Returns: String representation of Blockobject.Return type: str
-
data¶
-
index¶
-
previous_hash¶
-
proof¶
-
timestamp¶
-
blockchain.blockchain.blockchain module¶
-
class
blockchain.blockchain.blockchain.Blockchain(path_to_chain: str, json_format: bool, force_new_chain: bool)[source]¶ Bases:
object-
_load_chain() → None[source]¶ Helper method to load chain from disk. Raises an error if no chain is found.
Raises: ChainNotFoundError– Will be raised if no local chain could be found.
-
add_new_block(data: blockchain.blockchain.data.Data, proof: int, previous_hash: str) → blockchain.blockchain.block.Block[source]¶ Adds a new Block to the existing chain.
Parameters:
-
chain¶
-
genesis_block= | ================================================================================ | [1mindex[0m: 0 | [1mtime[0m: 1581268480.1071372 | [1mproof[0m: None | [1mprev. hash[0m: None | __________________________________________________________________ | [1mdata[0m: | id: 7134c40e0c604549b68bf48b63608fc8 | | message: This is the workload of the very first Block in this chain! | _________________________________________________________________ | ================================================================================ ¶
-
genesis_block_hash= '9ac2b6f3f9f89f0686727a82f8c783e03bb8c4a4486ebe7288710d4b6426e98b'¶
-
json_format¶
-
last_block¶
-
path_to_chain¶
-