aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-09-01 21:11:14 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-09-01 21:11:14 +0800
commit1f1d73ab747da9edc1c8f6bd39835e5653c539ee (patch)
treeef8b203e2626d1e0bda1c41007a04c20ea3014ad
parent9dc23ce284944d68ffc64cc4fb6f5d293a179fa0 (diff)
downloaddexon-1f1d73ab747da9edc1c8f6bd39835e5653c539ee.tar.gz
dexon-1f1d73ab747da9edc1c8f6bd39835e5653c539ee.tar.zst
dexon-1f1d73ab747da9edc1c8f6bd39835e5653c539ee.zip
eth/downloader: fix race causing occasional test failure
-rw-r--r--eth/downloader/downloader.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index 574f2ba15..73f95bf64 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -739,9 +739,11 @@ func (d *Downloader) fetchBlocks61(from uint64) error {
break
}
// Send a download request to all idle peers, until throttled
+ throttled := false
for _, peer := range d.peers.IdlePeers() {
// Short circuit if throttling activated
if d.queue.Throttle() {
+ throttled = true
break
}
// Reserve a chunk of hashes for a peer. A nil can mean either that
@@ -762,7 +764,7 @@ func (d *Downloader) fetchBlocks61(from uint64) error {
}
// Make sure that we have peers available for fetching. If all peers have been tried
// and all failed throw an error
- if !d.queue.Throttle() && d.queue.InFlight() == 0 {
+ if !throttled && d.queue.InFlight() == 0 {
return errPeersUnavailable
}
}