eth/downloader: fix flaw which prevented useless peers from being dropped

This commit is contained in:
Martin Holst Swende 2019-11-08 15:08:30 +01:00
parent e3d4a09150
commit 525f499c96
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

@ -1305,7 +1305,7 @@ func (d *Downloader) fetchParts(deliveryCh chan dataPack, deliver func(dataPack)
// Send a download request to all idle peers, until throttled // Send a download request to all idle peers, until throttled
progressed, throttled, running := false, false, inFlight() progressed, throttled, running := false, false, inFlight()
idles, total := idle() idles, total := idle()
pendCount := 1 pendCount := pending()
for _, peer := range idles { for _, peer := range idles {
// Short circuit if throttling activated // Short circuit if throttling activated
if throttled { if throttled {
@ -1330,7 +1330,9 @@ func (d *Downloader) fetchParts(deliveryCh chan dataPack, deliver func(dataPack)
throttled = true throttled = true
throttleCounter.Inc(1) throttleCounter.Inc(1)
} }
if request != nil { if request == nil {
continue
}
if request.From > 0 { if request.From > 0 {
peer.log.Trace("Requesting new batch of data", "type", kind, "from", request.From) peer.log.Trace("Requesting new batch of data", "type", kind, "from", request.From)
} else { } else {
@ -1348,7 +1350,6 @@ func (d *Downloader) fetchParts(deliveryCh chan dataPack, deliver func(dataPack)
// a much bigger issue. // a much bigger issue.
panic(fmt.Sprintf("%v: %s fetch assignment failed", peer, kind)) panic(fmt.Sprintf("%v: %s fetch assignment failed", peer, kind))
} }
}
running = true running = true
} }
// Make sure that we have peers available for fetching. If all peers have been tried // Make sure that we have peers available for fetching. If all peers have been tried