Let's build out the proofOfWork method, which we discussed in the preceding section:
- After the hashBlock method, define the proofOfWork method as follows:
Blockchain.prototype.proofOfWork = function() {}
- This method takes in two parameters: previousBlockHash and currentBlockData:
Blockchain.prototype.proofOfWork = function( previousBlockHash, currentBlockData) { }
- The first thing that we want to do inside of our method is define a nonce:
Blockchain.prototype.proofOfWork = function( previousBlockHash, currentBlockData) { let nonce = 0;}
- Next, we want to hash all of our data for the first time, so type in the following highlighted line of code:
Blockchain.prototype.proofOfWork = function( previousBlockHash, ...