eth: if our chain is better, propagate it back to peers

This commit is contained in:
Zergity 2019-03-02 00:37:10 +07:00
parent 0d71b2fc98
commit 9a05d3e761

View file

@ -171,7 +171,11 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
td := pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64()) td := pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64())
pHead, pTd := peer.Head() pHead, pTd := peer.Head()
if pTd.Cmp(td) <= 0 { if cmp := pTd.Cmp(td); cmp <= 0 {
if cmp < 0 {
// propagate our better chain back to peers
go pm.BroadcastBlock(currentBlock, true)
}
return return
} }
// Otherwise try to sync with the downloader // Otherwise try to sync with the downloader