From b70cd890e375e904b7f36b3d959e5656f5a5cbcd Mon Sep 17 00:00:00 2001 From: John Newbery Date: Mon, 24 Aug 2020 15:56:14 +0100 Subject: [net processing] Move MaybePunishNodeForBlock into PeerManager --- src/net_processing.cpp | 14 +++----------- src/net_processing.h | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/net_processing.cpp b/src/net_processing.cpp index fac0f100d4..79d1ebe3ab 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1132,17 +1132,9 @@ void Misbehaving(const NodeId pnode, const int howmuch, const std::string& messa } } -/** - * Potentially mark a node discouraged based on the contents of a BlockValidationState object - * - * @param[in] via_compact_block this bool is passed in because net_processing should - * punish peers differently depending on whether the data was provided in a compact - * block message or not. If the compact block had a valid header, but contained invalid - * txs, the peer should not be punished. See BIP 152. - * - * @return Returns true if the peer was punished (probably disconnected) - */ -static bool MaybePunishNodeForBlock(NodeId nodeid, const BlockValidationState& state, bool via_compact_block, const std::string& message = "") { +bool PeerManager::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidationState& state, + bool via_compact_block, const std::string& message) +{ switch (state.GetResult()) { case BlockValidationResult::BLOCK_RESULT_UNSET: break; diff --git a/src/net_processing.h b/src/net_processing.h index d4793ce303..c0a19f7bd2 100644 --- a/src/net_processing.h +++ b/src/net_processing.h @@ -11,6 +11,7 @@ #include #include +class BlockValidationState; class CBlockHeader; class CChainParams; class CTxMemPool; @@ -84,6 +85,19 @@ public: const std::chrono::microseconds time_received, const std::atomic& interruptMsgProc); private: + /** + * Potentially mark a node discouraged based on the contents of a BlockValidationState object + * + * @param[in] via_compact_block this bool is passed in because net_processing should + * punish peers differently depending on whether the data was provided in a compact + * block message or not. If the compact block had a valid header, but contained invalid + * txs, the peer should not be punished. See BIP 152. + * + * @return Returns true if the peer was punished (probably disconnected) + */ + bool MaybePunishNodeForBlock(NodeId nodeid, const BlockValidationState& state, + bool via_compact_block, const std::string& message = ""); + /** Maybe disconnect a peer and discourage future connections from its address. * * @param[in] pnode The node to check. -- cgit v1.2.3