Skip to content

Commit 55a471e

Browse files
authored
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.
1 parent 92106a6 commit 55a471e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

eth/downloader/beacondevsync.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ func (d *Downloader) GetHeader(hash common.Hash) (*types.Header, error) {
5252

5353
for _, peer := range d.peers.peers {
5454
if peer == nil {
55-
return nil, errors.New("could not find peer")
55+
log.Warn("Encountered nil peer while retrieving sync target", "hash", hash)
56+
continue
5657
}
5758
// Found a peer, attempt to retrieve the header whilst blocking and
5859
// retry if it fails for whatever reason

0 commit comments

Comments
 (0)