HomePhabricator

refactor: Pass Peer& to Misbehaving()

Description

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

Details

Provenance
PiRKAuthored on Dec 4 2023, 15:37
PiRKPushed on Dec 5 2023, 07:09
Reviewer
Restricted Project
Differential Revision
D14903: refactor: Pass Peer& to Misbehaving()
Parents
rABC7c2ad250ab6a: [Explorer] Update README with openssl and protoc dependencies
Branches
Unknown
Tags
Unknown