From dc6e98d2a8a084b0535f729587fb134e1715b3d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Wed, 18 Mar 2020 14:17:12 +0200 Subject: [PATCH] eth: when triggering a sync, check the head header TD, not block --- eth/handler.go | 4 ++-- eth/sync.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/eth/handler.go b/eth/handler.go index f103f1c37..236e50729 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -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 // a single block (as the true TD is below the propagated block), however this // scenario should easily be covered by the fetcher. - currentBlock := pm.blockchain.CurrentBlock() - if trueTD.Cmp(pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64())) > 0 { + currentHeader := pm.blockchain.CurrentHeader() + if trueTD.Cmp(pm.blockchain.GetTd(currentHeader.Hash(), currentHeader.Number.Uint64())) > 0 { go pm.synchronise(p) } } diff --git a/eth/sync.go b/eth/sync.go index d5c678a74..0709706c9 100644 --- a/eth/sync.go +++ b/eth/sync.go @@ -189,8 +189,8 @@ func (pm *ProtocolManager) synchronise(peer *peer) { return } // Make sure the peer's TD is higher than our own - currentBlock := pm.blockchain.CurrentBlock() - td := pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64()) + currentHeader := pm.blockchain.CurrentHeader() + td := pm.blockchain.GetTd(currentHeader.Hash(), currentHeader.Number.Uint64()) pHead, pTd := peer.Head() if pTd.Cmp(td) <= 0 {