aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-05-29 16:37:08 +0800
committerGitHub <noreply@github.com>2017-05-29 16:37:08 +0800
commitafb17cf071818cb7fd8954213db46f7d1411f273 (patch)
tree3a6f2cf91e1db4744b61f37e8fd7442cd574c681
parentcb809c03da18bf45f961a931dfd4c765de144e66 (diff)
parentafdd23b5cab227ae6edef3d78ec74b05c7872b55 (diff)
downloaddexon-afb17cf071818cb7fd8954213db46f7d1411f273.tar
dexon-afb17cf071818cb7fd8954213db46f7d1411f273.tar.gz
dexon-afb17cf071818cb7fd8954213db46f7d1411f273.tar.bz2
dexon-afb17cf071818cb7fd8954213db46f7d1411f273.tar.lz
dexon-afb17cf071818cb7fd8954213db46f7d1411f273.tar.xz
dexon-afb17cf071818cb7fd8954213db46f7d1411f273.tar.zst
dexon-afb17cf071818cb7fd8954213db46f7d1411f273.zip
Merge pull request #14524 from karalabe/noimport-during-fastsync
eth: don't import propagated blocks during fastsync
-rw-r--r--eth/handler.go5
-rw-r--r--eth/sync.go1
2 files changed, 6 insertions, 0 deletions
diff --git a/eth/handler.go b/eth/handler.go
index 16e371227..8c2f5660d 100644
--- a/eth/handler.go
+++ b/eth/handler.go
@@ -171,6 +171,11 @@ func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, ne
return blockchain.CurrentBlock().NumberU64()
}
inserter := func(blocks types.Blocks) (int, error) {
+ // If fast sync is running, deny importing weird blocks
+ if atomic.LoadUint32(&manager.fastSync) == 1 {
+ log.Warn("Discarded bad propagated block", "number", blocks[0].Number(), "hash", blocks[0].Hash())
+ return 0, nil
+ }
atomic.StoreUint32(&manager.acceptTxs, 1) // Mark initial sync done on any fetcher import
return manager.blockchain.InsertChain(blocks)
}
diff --git a/eth/sync.go b/eth/sync.go
index b0653acf9..8784b225d 100644
--- a/eth/sync.go
+++ b/eth/sync.go
@@ -183,6 +183,7 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
// 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.
+ atomic.StoreUint32(&pm.fastSync, 1)
mode = downloader.FastSync
}
if err := pm.downloader.Synchronise(peer.id, pHead, pTd, mode); err != nil {