fix: decrease block retry count when no peers found

There is a limitation in `downloadInternal` that infinitely loops for peers when attempting to download a block if the node does not have peers. Currently, the block retry counter is only decremented if there exists peers and a download attempt is made, otherwise the loop will continue until peers are found, ad infinium. This fix decrements the retry counter on each loop that no peers are found.
This commit is contained in:
Eric 2025-11-11 12:04:50 +11:00
parent 46413c8dff
commit e47186db90
No known key found for this signature in database

View File

@ -371,6 +371,12 @@ proc downloadInternal(
break break
# If we still don't have the block, we'll go for another cycle. # If we still don't have the block, we'll go for another cycle.
trace "No peers for block, will retry shortly" trace "No peers for block, will retry shortly"
# Without decremeting the retries count, this would infinitely loop
# trying to find peers.
self.pendingBlocks.decRetries(address)
# `searchForNewPeers` will do nothing if DiscoveryRateLimit has not
# elapsed, so we should wait to avoid a noop
await sleepAsync(DiscoveryRateLimit)
continue continue
# Once again, it might happen that the block was requested to a peer # Once again, it might happen that the block was requested to a peer