@@ -3723,32 +3723,32 @@ void ProcessMessage(
3723
3723
*/
3724
3724
bool PeerLogicValidation::MaybeDiscourageAndDisconnect (CNode& pnode)
3725
3725
{
3726
- NodeId peer_id{pnode.GetId ()};
3726
+ const NodeId peer_id{pnode.GetId ()};
3727
3727
{
3728
3728
LOCK (cs_main);
3729
- CNodeState & state = *State (peer_id);
3729
+ CNodeState& state = *State (peer_id);
3730
3730
3731
3731
// There's nothing to do if the m_should_discourage flag isn't set
3732
3732
if (!state.m_should_discourage ) return false ;
3733
3733
3734
- // Reset m_should_discourage
3735
3734
state.m_should_discourage = false ;
3736
3735
} // cs_main
3737
3736
3738
3737
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
3740
3739
LogPrintf (" Warning: not punishing noban peer %d!\n " , peer_id);
3741
3740
return false ;
3742
3741
}
3743
3742
3744
3743
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
3746
3745
LogPrintf (" Warning: not punishing manually connected peer %d!\n " , peer_id);
3747
3746
return false ;
3748
3747
}
3749
3748
3750
3749
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)
3752
3752
LogPrintf (" Warning: disconnecting but not discouraging local peer %d!\n " , peer_id);
3753
3753
pnode.fDisconnect = true ;
3754
3754
return true ;
0 commit comments