eth/downloader: skip nil peer in GetHeader (#32369)

The GetHeader function was incorrectly returning an error when
encountering nil peers in the peers list, which contradicted the comment 
"keep retrying if none are yet available". 

Changed the logic to skip nil peers with 'continue' instead of returning
an error, allowing the function to properly iterate through all
available peers and attempt to retrieve the target header from each valid peer.

This ensures the function behaves as intended - trying all available
peers before giving up, rather than failing on the first nil peer encountered.
This commit is contained in:
Forostovec 2025-08-11 16:34:59 +03:00 committed by GitHub
parent 92106a6b17
commit 55a471efaf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -52,7 +52,8 @@ func (d *Downloader) GetHeader(hash common.Hash) (*types.Header, error) {
for _, peer := range d.peers.peers {
if peer == nil {
return nil, errors.New("could not find peer")
log.Warn("Encountered nil peer while retrieving sync target", "hash", hash)
continue
}
// Found a peer, attempt to retrieve the header whilst blocking and
// retry if it fails for whatever reason