Building the Chain
The whole concept of a blockchain is based on the fact that the blocks are “chained” to each other. Now, we’ll create a blockchain class that will play the critical role of managing the entire chain.
It will keep the transactions data and include other helper methods for completing various roles, such as adding new blocks.
Let’s talk about the helper methods.
Adding the Constructor Method
Here is the code:
self.chain = 
self.current_data = 
self.nodes = set()
__init__() constructor method is what instantiates the blockchain.
Here are the roles of its attributes:
- self.chain — this variable stores all the blocks.
- self.current_data — this variable stores information about the transactions in the block.
- self.build_genesis() — this method is used to create the initial block in the chain.