mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Pass Peer& to Misbehaving()
`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 commit is contained in:
@@ -71,12 +71,8 @@ public:
|
||||
/** Set the best height */
|
||||
virtual void SetBestHeight(int height) = 0;
|
||||
|
||||
/**
|
||||
* Increment peer's misbehavior score. If the new value >= DISCOURAGEMENT_THRESHOLD, mark the node
|
||||
* to be discouraged, meaning the peer might be disconnected and added to the discouragement filter.
|
||||
* Public for unit testing.
|
||||
*/
|
||||
virtual void Misbehaving(const NodeId pnode, const int howmuch, const std::string& message) = 0;
|
||||
/* Public for unit testing. */
|
||||
virtual void UnitTestMisbehaving(NodeId peer_id, int howmuch) = 0;
|
||||
|
||||
/**
|
||||
* Evict extra outbound peers. If we think our tip may be stale, connect to an extra outbound.
|
||||
|
||||
Reference in New Issue
Block a user