-
Notifications
You must be signed in to change notification settings - Fork 38.8k
refactor: Pass Peer& to Misbehaving() #25144
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
The head ref may contain hidden characters: "2205-mis-peer-\u{1F6E5}"
Conversation
src/net_processing.cpp
Outdated
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.
Seems like the MaybePunish* calls could accept a Peer& (and CNodeState&) as well, and also not be called when the peer is already disconnected?
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.
Yes, but only because the message happens to be empty() in cases where the peer might be nullptr/disconnected. I wasn't sure if we want to enforce this correlation.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
vasild
left a comment
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.
ACK fa825d1903a3d7268104df33b7dcf1a5e685302d
The commit message is rather scarce. It is better if it contains all the info from the PR description. The latter is not part of the immutable git history and may be harder to access, especially if we move away from github at some point.
`Misbehaving` has several coding related issues (ignoring the conceptual issues here for now): * It is public, but it is not supposed to be called from outside of net_processing. Fix that by making it private and creating a public `UnitTestMisbehaving` method for unit testing only. * It doesn't do anything if a `nullptr` is passed. It would be less confusing to just skip the call instead. Fix that by passing `Peer&` to `Misbehaving()`. * It calls `GetPeerRef`, causing `!m_peer_mutex` lock annotations to be propagated. This is harmless, but verbose. Fix it by removing the no longer needed call to `GetPeerRef` and the no longer needed lock annotations.
vasild
left a comment
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.
ACK fa8aa0a
|
LGTM, otherwise, but did only cursory code review. |
w0xlt
left a comment
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.
Code Review ACK fa8aa0a
Misbehavinghas several coding related issues (ignoring the conceptual issues here for now):UnitTestMisbehavingmethod for unit testing only.nullptris passed. It would be less confusing to just skip the call instead. Fix that by passingPeer&toMisbehaving().GetPeerRef, causing!m_peer_mutexlock annotations to be propagated. This is harmless, but verbose. Fix it by removing the no longer needed call toGetPeerRefand the no longer needed lock annotations.