Starting the node server
As we learned in the first chapter, a copy of the blockchain is maintained on the nodes that participate in the network, and this is what makes blockchains decentralized since a copy of the blockchain exists on multiple nodes, each of which acts as a server. Even if one node goes down or a copy is deleted, other nodes are still there to uphold the blockchain network.
So far, we have built the blocks, mined them, added them, and connected them to the blockchain by updating the block tree. Now, it’s time to see how blockchain copies are maintained on the nodes, and before that, we will need to start a server.
In this section, we will go through some code that will help us start servers and help operate nodes for our blockchain network.
The server
In the project’s GitHub repository, readers will discover a file named server.rs
, dedicated to hosting the necessary code for initializing a server.
The crates that you see in the first line...