aboutsummaryrefslogtreecommitdiffstats
path: root/eth/sync.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-03-22 08:37:24 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-03-22 08:37:24 +0800
commit9b84caf3a5f55cc2a14b50291118b9fab668b8c2 (patch)
tree0c9f92abf034f6a3e8f0cbc7458b209331fd7c8f /eth/sync.go
parent06d6685eb58f6cb0eda4d7adc8ae91e5cdb88462 (diff)
downloaddexon-9b84caf3a5f55cc2a14b50291118b9fab668b8c2.tar
dexon-9b84caf3a5f55cc2a14b50291118b9fab668b8c2.tar.gz
dexon-9b84caf3a5f55cc2a14b50291118b9fab668b8c2.tar.bz2
dexon-9b84caf3a5f55cc2a14b50291118b9fab668b8c2.tar.lz
dexon-9b84caf3a5f55cc2a14b50291118b9fab668b8c2.tar.xz
dexon-9b84caf3a5f55cc2a14b50291118b9fab668b8c2.tar.zst
dexon-9b84caf3a5f55cc2a14b50291118b9fab668b8c2.zip
core, eth, les: support resuming fast sync on heavy rollback (#3743)
Diffstat (limited to 'eth/sync.go')
-rw-r--r--eth/sync.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/eth/sync.go b/eth/sync.go
index 6e2c7c432..f2cae6c19 100644
--- a/eth/sync.go
+++ b/eth/sync.go
@@ -175,6 +175,14 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
// Otherwise try to sync with the downloader
mode := downloader.FullSync
if atomic.LoadUint32(&pm.fastSync) == 1 {
+ // Fast sync was explicitly requested, and explicitly granted
+ mode = downloader.FastSync
+ } else if currentBlock.NumberU64() == 0 && pm.blockchain.CurrentFastBlock().NumberU64() > 0 {
+ // The database seems empty as the current block is the genesis. Yet the fast
+ // block is ahead, so fast sync was enabled for this node at a certain point.
+ // The only scenario where this can happen is if the user manually (or via a
+ // bad block) rolled back a fast sync node below the sync point. In this case
+ // however it's safe to reenable fast sync.
mode = downloader.FastSync
}
if err := pm.downloader.Synchronise(peer.id, pHead, pTd, mode); err != nil {