Skip to content

Commit e2d7c1a

Browse files
committed
Merge pull request #1752 from karalabe/fix-eth61-test
eth/downloader: fix race causing occasional test failure
2 parents ebbe25e + 1f1d73a commit e2d7c1a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

eth/downloader/downloader.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,9 +739,11 @@ func (d *Downloader) fetchBlocks61(from uint64) error {
739739
break
740740
}
741741
// Send a download request to all idle peers, until throttled
742+
throttled := false
742743
for _, peer := range d.peers.IdlePeers() {
743744
// Short circuit if throttling activated
744745
if d.queue.Throttle() {
746+
throttled = true
745747
break
746748
}
747749
// 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 {
762764
}
763765
// Make sure that we have peers available for fetching. If all peers have been tried
764766
// and all failed throw an error
765-
if !d.queue.Throttle() && d.queue.InFlight() == 0 {
767+
if !throttled && d.queue.InFlight() == 0 {
766768
return errPeersUnavailable
767769
}
768770
}

0 commit comments

Comments
 (0)