Let's refactor the /mine endpoint by implementing the following steps:
- Head over to the dev/networkNode.js file. In the /mine endpoint, beneath the part where we had defined the newBlock variable, let's add the functionality to broadcast the new block to all the other nodes in the network. To do this, follow the same process that we introduced in the previous sections—that is, to loop through all the other nodes inside the network, make a request to the nodes, and send the newBlock variable as data:
bitcoin.networkNodes.forEach(networkNodeUrl => {})
The preceding line mentions that for each of the networkNodes, we're going to make a request and send along the newBlock.
- We then need some request options ...