refactor: Pass Peer& to Misbehaving()
Summary:
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.
This is a backport of core#25144
See D384 for why we already had an overloaded Mishbehaving for CNode
Test Plan:
With clang and debug
ninja all check-all
Reviewers: #bitcoin_abc, bytesofman
Reviewed By: #bitcoin_abc, bytesofman
Subscribers: bytesofman
Differential Revision: https://reviews.bitcoinabc.org/D14903