aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.h
diff options
context:
space:
mode:
authorMacroFake <falke.marco@gmail.com>2022-05-16 16:45:53 +0200
committerMacroFake <falke.marco@gmail.com>2022-05-27 16:59:45 +0200
commitfa8aa0aa8180c3a0369c7589b8747666778a0deb (patch)
treefbcf67e1dc84ff00236a5a0faee5511d02be8e32 /src/net_processing.h
parent3ba6dd6f4bb42bfab48194ce5f44850b0109451a (diff)
downloadbitcoin-fa8aa0aa8180c3a0369c7589b8747666778a0deb.tar.xz
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.
Diffstat (limited to 'src/net_processing.h')
-rw-r--r--src/net_processing.h8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/net_processing.h b/src/net_processing.h
index d5c73e6c79..5fbae98c27 100644
--- a/src/net_processing.h
+++ b/src/net_processing.h
@@ -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.