Skip to content

Commit b70cd89

Browse files
committed
[net processing] Move MaybePunishNodeForBlock into PeerManager
1 parent d777835 commit b70cd89

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/net_processing.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,17 +1132,9 @@ void Misbehaving(const NodeId pnode, const int howmuch, const std::string& messa
11321132
}
11331133
}
11341134

1135-
/**
1136-
* Potentially mark a node discouraged based on the contents of a BlockValidationState object
1137-
*
1138-
* @param[in] via_compact_block this bool is passed in because net_processing should
1139-
* punish peers differently depending on whether the data was provided in a compact
1140-
* block message or not. If the compact block had a valid header, but contained invalid
1141-
* txs, the peer should not be punished. See BIP 152.
1142-
*
1143-
* @return Returns true if the peer was punished (probably disconnected)
1144-
*/
1145-
static bool MaybePunishNodeForBlock(NodeId nodeid, const BlockValidationState& state, bool via_compact_block, const std::string& message = "") {
1135+
bool PeerManager::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidationState& state,
1136+
bool via_compact_block, const std::string& message)
1137+
{
11461138
switch (state.GetResult()) {
11471139
case BlockValidationResult::BLOCK_RESULT_UNSET:
11481140
break;

src/net_processing.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <sync.h>
1212
#include <validationinterface.h>
1313

14+
class BlockValidationState;
1415
class CBlockHeader;
1516
class CChainParams;
1617
class CTxMemPool;
@@ -84,6 +85,19 @@ class PeerManager final : public CValidationInterface, public NetEventsInterface
8485
const std::chrono::microseconds time_received, const std::atomic<bool>& interruptMsgProc);
8586

8687
private:
88+
/**
89+
* Potentially mark a node discouraged based on the contents of a BlockValidationState object
90+
*
91+
* @param[in] via_compact_block this bool is passed in because net_processing should
92+
* punish peers differently depending on whether the data was provided in a compact
93+
* block message or not. If the compact block had a valid header, but contained invalid
94+
* txs, the peer should not be punished. See BIP 152.
95+
*
96+
* @return Returns true if the peer was punished (probably disconnected)
97+
*/
98+
bool MaybePunishNodeForBlock(NodeId nodeid, const BlockValidationState& state,
99+
bool via_compact_block, const std::string& message = "");
100+
87101
/** Maybe disconnect a peer and discourage future connections from its address.
88102
*
89103
* @param[in] pnode The node to check.

0 commit comments

Comments
 (0)