mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth/downloader: fix flaw which prevented useless peers from being dropped
This commit is contained in:
parent
e3d4a09150
commit
525f499c96
1 changed files with 20 additions and 19 deletions
|
|
@ -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,24 +1330,25 @@ 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 {
|
||||||
if request.From > 0 {
|
continue
|
||||||
peer.log.Trace("Requesting new batch of data", "type", kind, "from", request.From)
|
}
|
||||||
} else {
|
if request.From > 0 {
|
||||||
peer.log.Trace("Requesting new batch of data", "type", kind, "count", len(request.Headers), "from", request.Headers[0].Number)
|
peer.log.Trace("Requesting new batch of data", "type", kind, "from", request.From)
|
||||||
}
|
} else {
|
||||||
// Fetch the chunk and make sure any errors return the hashes to the queue
|
peer.log.Trace("Requesting new batch of data", "type", kind, "count", len(request.Headers), "from", request.Headers[0].Number)
|
||||||
if fetchHook != nil {
|
}
|
||||||
fetchHook(request.Headers)
|
// Fetch the chunk and make sure any errors return the hashes to the queue
|
||||||
}
|
if fetchHook != nil {
|
||||||
if err := fetch(peer, request); err != nil {
|
fetchHook(request.Headers)
|
||||||
// Although we could try and make an attempt to fix this, this error really
|
}
|
||||||
// means that we've double allocated a fetch task to a peer. If that is the
|
if err := fetch(peer, request); err != nil {
|
||||||
// case, the internal state of the downloader and the queue is very wrong so
|
// Although we could try and make an attempt to fix this, this error really
|
||||||
// better hard crash and note the error instead of silently accumulating into
|
// means that we've double allocated a fetch task to a peer. If that is the
|
||||||
// a much bigger issue.
|
// case, the internal state of the downloader and the queue is very wrong so
|
||||||
panic(fmt.Sprintf("%v: %s fetch assignment failed", peer, kind))
|
// better hard crash and note the error instead of silently accumulating into
|
||||||
}
|
// a much bigger issue.
|
||||||
|
panic(fmt.Sprintf("%v: %s fetch assignment failed", peer, kind))
|
||||||
}
|
}
|
||||||
running = true
|
running = true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue