Merge bitcoin/bitcoin#36707: net_processing: remove redundant `peer` check in `MaybePunishNodeForBlock`
What changed, and why it matters
This is a tiny code cleanup in Bitcoin Core's network handling. It removes an unnecessary second check that 'peer' exists, because the surrounding code already confirmed it exists. There is no functional change and no security risk.
No action needed. This is a non-security refactoring change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit removes a redundant if (peer) guard before Misbehaving(*peer, message) inside an existing if (peer && !via_compact_block && !peer->m_is_inbound) block. The inner check was always true when reached, so this is a pure refactor with no behavioral or security impact.
Changed components
src/net_processing.cppMaybePunishNodeForBlockInspect captured patch +1 / −1
### src/net_processing.cpp
@@ -2049,7 +2049,7 @@ void PeerManagerImpl::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidati
// Discourage outbound (but not inbound) peers if on an invalid chain.
// Exempt HB compact block peers. Manual connections are always protected from discouragement.
if (peer && !via_compact_block && !peer->m_is_inbound) {
- if (peer) Misbehaving(*peer, message);
+ Misbehaving(*peer, message);
return;
}
break;Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.