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 passingPeer&
toMisbehaving()
. - 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 toGetPeerRef
and the no longer needed lock annotations.