mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
eth/downloader: fix crash when there are no results that have been downloaded
This commit is contained in:
parent
3782d2ac67
commit
c8f9d6bb90
1 changed files with 6 additions and 4 deletions
|
|
@ -375,10 +375,12 @@ func (q *queue) Results(block bool) []*fetchResult {
|
||||||
|
|
||||||
results := q.resultCache.GetCompleted(maxResultsProcess)
|
results := q.resultCache.GetCompleted(maxResultsProcess)
|
||||||
|
|
||||||
// set a throttle threshhold based on estimated worst-sized block that can be created for a given gas limit.
|
if len(results) > 0 {
|
||||||
gasLimit := max(results[0].Header.GasLimit, 1)
|
// set a throttle threshhold based on estimated worst-sized block that can be created for a given gas limit.
|
||||||
throttleThreshold := min(uint64(blockCacheMemory)/(gasLimit/10), 2048)
|
gasLimit := max(results[0].Header.GasLimit, 10)
|
||||||
throttleThreshold = q.resultCache.SetThrottleThreshold(throttleThreshold)
|
throttleThreshold := min(uint64(blockCacheMemory)/(gasLimit/10), 2048)
|
||||||
|
throttleThreshold = q.resultCache.SetThrottleThreshold(throttleThreshold)
|
||||||
|
}
|
||||||
|
|
||||||
// With results removed from the cache, wake throttled fetchers
|
// With results removed from the cache, wake throttled fetchers
|
||||||
for _, ch := range []chan bool{q.blockWakeCh, q.receiptWakeCh} {
|
for _, ch := range []chan bool{q.blockWakeCh, q.receiptWakeCh} {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue