Skip to content

Commit 57fd2da

Browse files
committed
eth: only disable fast sync after success
1 parent aa9432b commit 57fd2da

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

‎eth/sync.go‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,18 +189,13 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
189189
mode = downloader.FastSync
190190
}
191191
// Run the sync cycle, and disable fast sync if we've went past the pivot block
192-
err := pm.downloader.Synchronise(peer.id, pHead, pTd, mode)
193-
194-
if atomic.LoadUint32(&pm.fastSync) == 1 {
195-
// Disable fast sync if we indeed have something in our chain
196-
if pm.blockchain.CurrentBlock().NumberU64() > 0 {
197-
log.Info("Fast sync complete, auto disabling")
198-
atomic.StoreUint32(&pm.fastSync, 0)
199-
}
200-
}
201-
if err != nil {
192+
if err := pm.downloader.Synchronise(peer.id, pHead, pTd, mode); err != nil {
202193
return
203194
}
195+
if atomic.LoadUint32(&pm.fastSync) == 1 {
196+
log.Info("Fast sync complete, auto disabling")
197+
atomic.StoreUint32(&pm.fastSync, 0)
198+
}
204199
atomic.StoreUint32(&pm.acceptTxs, 1) // Mark initial sync done
205200
if head := pm.blockchain.CurrentBlock(); head.NumberU64() > 0 {
206201
// We've completed a sync cycle, notify all peers of new state. This path is

0 commit comments

Comments
 (0)