* 产生同步的条件
在区块的同步过程中,一个节点每次只会与另外其他一个进行同步,并且只有出现以下三种情况之一的时候节点之间才会开启一次同步:
- 节点N connect一个新节点P,P有更大的总难度值(P节点的区块链长度更长)时,N和P之间开启一次同步
- 与N已经connect的节点P通告它的total difficult值比N要大,N和P之间开启一次同步
- N收到一个比当前其区块链上的头结点的total difficulty值更大的区块,并且在N的链中找不到这个接收到的区块的祖先节点
文献原文:
A node will only synchronise with one other node at a time. A node N starts a block synchronisation in the following cases:
1. N starts a connection to a new peer with higher advertised total difficulty(e.g. after joining or rejoining the network).
2. A node advertising a higher total difficulty than N connects to N.
3. N receives a block with higher total difficulty than the head of its current blockchain and is missing some of the block’s ancestors.
* 同步的详细过程
Node N with lower total diffficulty