-
Notifications
You must be signed in to change notification settings - Fork 21.1k
eth/downloader: skip nil peer in GetHeader #32369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eth/downloader: skip nil peer in GetHeader #32369
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better if we log out the case rather than directly continuing for feedback
@@ -52,7 +52,7 @@ func (d *Downloader) GetHeader(hash common.Hash) (*types.Header, error) { | |||
|
|||
for _, peer := range d.peers.peers { | |||
if peer == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a warning level log here, indicating the nil peer is encountered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a warning level log here, indicating the nil peer is encountered.
Yes, done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe bit late for this comment, but I'm not too happy about the log message. Log messages are for users, but this warning is not something the user has any chance of fixing. I honestly don't know when a nil
peer will even be encountered here. So it'd be good to research why this condition can happen, and fix it, instead of printing a weird warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
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.