January 2019
Beginner to intermediate
372 pages
11h 17m
English
The following example will illustrate how to find a nonce by brute force, with the help of the SHA-256 algorithm, in order to find a hash value that will satisfy the target hash. The target hash value is determined by setting the difficulty bits in the Proof of Work algorithm. We will modify the blockchain linker that we created earlier on to include the Proof of Work algorithm while creating a new block. Firstly, let's modify a few functions of the blockchain example to include the consensus algorithm.
The Block class used to create a new block to be added to blockchain is modified to take two extra members, called difficulty_bits and nonce. We'll also include difficulty_bits in the header ...