Skip to content

Commit 634144a

Browse files
committed
[net processing] Fixup MaybeDiscourageAndDisconnect() style
Based on review comments from Marco Falke and Jon Atack.
1 parent 40a0481 commit 634144a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/net_processing.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3723,32 +3723,32 @@ void ProcessMessage(
37233723
*/
37243724
bool PeerLogicValidation::MaybeDiscourageAndDisconnect(CNode& pnode)
37253725
{
3726-
NodeId peer_id{pnode.GetId()};
3726+
const NodeId peer_id{pnode.GetId()};
37273727
{
37283728
LOCK(cs_main);
3729-
CNodeState &state = *State(peer_id);
3729+
CNodeState& state = *State(peer_id);
37303730

37313731
// There's nothing to do if the m_should_discourage flag isn't set
37323732
if (!state.m_should_discourage) return false;
37333733

3734-
// Reset m_should_discourage
37353734
state.m_should_discourage = false;
37363735
} // cs_main
37373736

37383737
if (pnode.HasPermission(PF_NOBAN)) {
3739-
// Peer has the NOBAN permission flag - log but don't disconnect
3738+
// We never disconnect or discourage peers for bad behavior if they have the NOBAN permission flag
37403739
LogPrintf("Warning: not punishing noban peer %d!\n", peer_id);
37413740
return false;
37423741
}
37433742

37443743
if (pnode.m_manual_connection) {
3745-
// Peer is a manual connection - log but don't disconnect
3744+
// We never disconnect or discourage manual peers for bad behavior
37463745
LogPrintf("Warning: not punishing manually connected peer %d!\n", peer_id);
37473746
return false;
37483747
}
37493748

37503749
if (pnode.addr.IsLocal()) {
3751-
// Peer is on a local address. Disconnect this peer, but don't discourage the local address
3750+
// We disconnect local peers for bad behavior but don't discourage (since that would discourage
3751+
// all peers on the same local address)
37523752
LogPrintf("Warning: disconnecting but not discouraging local peer %d!\n", peer_id);
37533753
pnode.fDisconnect = true;
37543754
return true;

0 commit comments

Comments
 (0)