aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader
diff options
context:
space:
mode:
authorMartin Holst Swende <martin@swende.se>2018-02-05 21:38:06 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-02-05 21:38:06 +0800
commitbc0666fb277be5e7d1fd7c5523a3b335b310a154 (patch)
treecb55402107ba9f965975c8bfac26703f63b58b52 /eth/downloader
parent0662384d294eaa44390799747db030e8d401111d (diff)
downloadgo-tangerine-bc0666fb277be5e7d1fd7c5523a3b335b310a154.tar
go-tangerine-bc0666fb277be5e7d1fd7c5523a3b335b310a154.tar.gz
go-tangerine-bc0666fb277be5e7d1fd7c5523a3b335b310a154.tar.bz2
go-tangerine-bc0666fb277be5e7d1fd7c5523a3b335b310a154.tar.lz
go-tangerine-bc0666fb277be5e7d1fd7c5523a3b335b310a154.tar.xz
go-tangerine-bc0666fb277be5e7d1fd7c5523a3b335b310a154.tar.zst
go-tangerine-bc0666fb277be5e7d1fd7c5523a3b335b310a154.zip
eth/downloader: fix #15858 by checking if downloader dropPeer function is set (#15992)
Diffstat (limited to 'eth/downloader')
-rw-r--r--eth/downloader/downloader.go23
1 files changed, 20 insertions, 3 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index 6ce58257b..746c6a402 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -324,8 +324,13 @@ func (d *Downloader) Synchronise(id string, head common.Hash, td *big.Int, mode
errEmptyHeaderSet, errPeersUnavailable, errTooOld,
errInvalidAncestor, errInvalidChain:
log.Warn("Synchronisation failed, dropping peer", "peer", id, "err", err)
- d.dropPeer(id)
-
+ if d.dropPeer == nil {
+ // The dropPeer method is nil when `--copydb` is used for a local copy.
+ // Timeouts can occur if e.g. compaction hits at the wrong time, and can be ignored
+ log.Warn("Downloader wants to drop peer, but peerdrop-function is not set", "peer", id)
+ } else {
+ d.dropPeer(id)
+ }
default:
log.Warn("Synchronisation failed, retrying", "err", err)
}
@@ -853,6 +858,12 @@ func (d *Downloader) fetchHeaders(p *peerConnection, from uint64) error {
getHeaders(from)
case <-timeout.C:
+ if d.dropPeer == nil {
+ // The dropPeer method is nil when `--copydb` is used for a local copy.
+ // Timeouts can occur if e.g. compaction hits at the wrong time, and can be ignored
+ p.log.Warn("Downloader wants to drop peer, but peerdrop-function is not set", "peer", p.id)
+ break
+ }
// Header retrieval timed out, consider the peer bad and drop
p.log.Debug("Header request timed out", "elapsed", ttl)
headerTimeoutMeter.Mark(1)
@@ -1071,7 +1082,13 @@ func (d *Downloader) fetchParts(errCancel error, deliveryCh chan dataPack, deliv
setIdle(peer, 0)
} else {
peer.log.Debug("Stalling delivery, dropping", "type", kind)
- d.dropPeer(pid)
+ if d.dropPeer == nil {
+ // The dropPeer method is nil when `--copydb` is used for a local copy.
+ // Timeouts can occur if e.g. compaction hits at the wrong time, and can be ignored
+ peer.log.Warn("Downloader wants to drop peer, but peerdrop-function is not set", "peer", pid)
+ } else {
+ d.dropPeer(pid)
+ }
}
}
}