January 2019
Beginner to intermediate
372 pages
11h 17m
English
Although the blockchain part of the application is pretty similar to the application created in Chapter 4, Networking in Blockchain, we have added some functionality due to the introduction of the transaction data structure.
Mining a blockchain without transactions is straightforward; it just entails the construction of a block with a header and data. But when the arbitrary data is replaced with transaction data, the node needs to fetch the transactions from the local transaction pool:
def construct_next_block(self):
coinbase_tx = get_coinbase_transaction(get_public_from_wallet(), self.blocks[-1].index + 1)
block_data = [coinbase_tx] + get_transaction_pool()
return self.generate_next_block(block_data)
This method constructs and ...
Read now
Unlock full access