diff options
author | gary rong <garyrong0905@gmail.com> | 2018-03-09 17:51:30 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-03-09 17:51:30 +0800 |
commit | 77da203547b83c70d12552a86bb7beee52f6383e (patch) | |
tree | 66074b1a60b022333bc3872d0e0a31ec58bda624 /eth/sync.go | |
parent | 307846d046d66c04ec9750c2219f7c93b53cb2c9 (diff) | |
download | dexon-77da203547b83c70d12552a86bb7beee52f6383e.tar.gz dexon-77da203547b83c70d12552a86bb7beee52f6383e.tar.zst dexon-77da203547b83c70d12552a86bb7beee52f6383e.zip |
eth: update higest block we know during the sync if a higher was found (#16283)
* eth: update higest block we know during the sync if a higher was found
* eth: avoid useless sync in fast sync
Diffstat (limited to 'eth/sync.go')
-rw-r--r-- | eth/sync.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/eth/sync.go b/eth/sync.go index 2da1464bc..e49e40087 100644 --- a/eth/sync.go +++ b/eth/sync.go @@ -188,6 +188,14 @@ func (pm *ProtocolManager) synchronise(peer *peer) { atomic.StoreUint32(&pm.fastSync, 1) mode = downloader.FastSync } + + if mode == downloader.FastSync { + // Make sure the peer's total difficulty we are synchronizing is higher. + if pm.blockchain.GetTdByHash(pm.blockchain.CurrentFastBlock().Hash()).Cmp(pTd) >= 0 { + return + } + } + // Run the sync cycle, and disable fast sync if we've went past the pivot block if err := pm.downloader.Synchronise(peer.id, pHead, pTd, mode); err != nil { return |