diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-07-25 20:14:14 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-07-25 20:14:14 +0800 |
commit | 1dd272080dfb49a07a87c46e18d8aeaa0fd41a08 (patch) | |
tree | ec47d1ede87ac09607689277e0b90f40712556fe /eth/sync.go | |
parent | 771655e3fee585ce4bc47dfaa279557c6c1c2421 (diff) | |
download | go-tangerine-1dd272080dfb49a07a87c46e18d8aeaa0fd41a08.tar.gz go-tangerine-1dd272080dfb49a07a87c46e18d8aeaa0fd41a08.tar.zst go-tangerine-1dd272080dfb49a07a87c46e18d8aeaa0fd41a08.zip |
eth, eth/downloader: better remote head tracking
Diffstat (limited to 'eth/sync.go')
-rw-r--r-- | eth/sync.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/eth/sync.go b/eth/sync.go index 23cf18c8d..e1946edda 100644 --- a/eth/sync.go +++ b/eth/sync.go @@ -161,10 +161,12 @@ func (pm *ProtocolManager) synchronise(peer *peer) { if peer == nil { return } - // Make sure the peer's TD is higher than our own. If not drop. + // Make sure the peer's TD is higher than our own currentBlock := pm.blockchain.CurrentBlock() td := pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64()) - if peer.Td().Cmp(td) <= 0 { + + pHead, pTd := peer.Head() + if pTd.Cmp(td) <= 0 { return } // Otherwise try to sync with the downloader @@ -172,7 +174,7 @@ func (pm *ProtocolManager) synchronise(peer *peer) { if atomic.LoadUint32(&pm.fastSync) == 1 { mode = downloader.FastSync } - if err := pm.downloader.Synchronise(peer.id, peer.Head(), peer.Td(), mode); err != nil { + if err := pm.downloader.Synchronise(peer.id, pHead, pTd, mode); err != nil { return } atomic.StoreUint32(&pm.synced, 1) // Mark initial sync done |