eth: when triggering a sync, check the head header TD, not block

This commit is contained in:
Péter Szilágyi 2020-03-18 14:17:12 +02:00
parent 5dd0cd12ec
commit dc6e98d2a8
No known key found for this signature in database
GPG Key ID: E9AE538CEDF8293D
2 changed files with 4 additions and 4 deletions

View File

@ -727,8 +727,8 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
// Schedule a sync if above ours. Note, this will not fire a sync for a gap of // Schedule a sync if above ours. Note, this will not fire a sync for a gap of
// a single block (as the true TD is below the propagated block), however this // a single block (as the true TD is below the propagated block), however this
// scenario should easily be covered by the fetcher. // scenario should easily be covered by the fetcher.
currentBlock := pm.blockchain.CurrentBlock() currentHeader := pm.blockchain.CurrentHeader()
if trueTD.Cmp(pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64())) > 0 { if trueTD.Cmp(pm.blockchain.GetTd(currentHeader.Hash(), currentHeader.Number.Uint64())) > 0 {
go pm.synchronise(p) go pm.synchronise(p)
} }
} }

View File

@ -189,8 +189,8 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
return return
} }
// Make sure the peer's TD is higher than our own // Make sure the peer's TD is higher than our own
currentBlock := pm.blockchain.CurrentBlock() currentHeader := pm.blockchain.CurrentHeader()
td := pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64()) td := pm.blockchain.GetTd(currentHeader.Hash(), currentHeader.Number.Uint64())
pHead, pTd := peer.Head() pHead, pTd := peer.Head()
if pTd.Cmp(td) <= 0 { if pTd.Cmp(td) <= 0 {