aboutsummaryrefslogtreecommitdiffstats
path: root/eth/sync.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-09-06 20:02:44 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-09-06 20:02:44 +0800
commitf30179d62e239521290690ac0688da8648ddebc6 (patch)
tree0da8782be0371d766d1b7814aab96a5d860c2fc5 /eth/sync.go
parentc4d21bc8e548d909d5b2940cb00d3d068f5697ec (diff)
downloaddexon-f30179d62e239521290690ac0688da8648ddebc6.tar
dexon-f30179d62e239521290690ac0688da8648ddebc6.tar.gz
dexon-f30179d62e239521290690ac0688da8648ddebc6.tar.bz2
dexon-f30179d62e239521290690ac0688da8648ddebc6.tar.lz
dexon-f30179d62e239521290690ac0688da8648ddebc6.tar.xz
dexon-f30179d62e239521290690ac0688da8648ddebc6.tar.zst
dexon-f30179d62e239521290690ac0688da8648ddebc6.zip
eth: disable fast sync after pivot is committed
Diffstat (limited to 'eth/sync.go')
-rw-r--r--eth/sync.go20
1 files changed, 11 insertions, 9 deletions
diff --git a/eth/sync.go b/eth/sync.go
index 7442f912c..a8ae64617 100644
--- a/eth/sync.go
+++ b/eth/sync.go
@@ -188,7 +188,17 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
atomic.StoreUint32(&pm.fastSync, 1)
mode = downloader.FastSync
}
- if err := pm.downloader.Synchronise(peer.id, pHead, pTd, mode); err != nil {
+ // Run the sync cycle, and disable fast sync if we've went past the pivot block
+ err := pm.downloader.Synchronise(peer.id, pHead, pTd, mode)
+
+ if atomic.LoadUint32(&pm.fastSync) == 1 {
+ // Disable fast sync if we indeed have something in our chain
+ if pm.blockchain.CurrentBlock().NumberU64() > 0 {
+ log.Info("Fast sync complete, auto disabling")
+ atomic.StoreUint32(&pm.fastSync, 0)
+ }
+ }
+ if err != nil {
return
}
atomic.StoreUint32(&pm.acceptTxs, 1) // Mark initial sync done
@@ -201,12 +211,4 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
// more reliably update peers or the local TD state.
go pm.BroadcastBlock(head, false)
}
- // If fast sync was enabled, and we synced up, disable it
- if atomic.LoadUint32(&pm.fastSync) == 1 {
- // Disable fast sync if we indeed have something in our chain
- if pm.blockchain.CurrentBlock().NumberU64() > 0 {
- log.Info("Fast sync complete, auto disabling")
- atomic.StoreUint32(&pm.fastSync, 0)
- }
- }
}