Building  the /register-and-broadcast-node endpoint 

Let's start building our register and broadcast node endpoint. The function of this endpoint will be to register the new node with itself and then broadcast the new node to all the other nodes that are already present in the network. So, let's get started with building the endpoint:

  1. From the preceding sections, in the dev/networkNode.js file, we already have the following code:
app.post('/register-and-broadcast-node', function(req, res) {       const newNodeUrl = req.body.newNodeUrl;

Here, we defined a variable called newNodeUrl, and this newNodeUrl data will be passed onto the request body, similar to how we have transaction data being passed into the transaction endpoint. With access to the ...

Get Learn Blockchain Programming with JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.