Foundations of Blockchain
上QQ阅读APP看书,第一时间看更新

Initial block synchronization

When a new node joins a network, it connects to one of the available peers in the network; it then tries to exchange its block information with the peer, and updates the local blockchain, if required.

Figure 4.4: Initial block synchronization

The node sends a chain length or last block query message after connecting to the peer. Requesting the chain length is equivalent to requesting the last block to identify its index. If the received block cannot be appended to the local blockchain due the hash mismatch, then the node sends a message to its peer asking it to send all the blocks. The node can also broadcast a message requesting all the blocks to ensure that it receives the longest chain.