Skip to content

Commit

Permalink
[net processing] Move MaybePunishPeerForTx to PeerManager
Browse files Browse the repository at this point in the history
  • Loading branch information
jnewbery committed Sep 7, 2020
1 parent e662e2d commit 3115e00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 1 addition & 6 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1182,12 +1182,7 @@ bool PeerManager::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidationSt
return false;
}

/**
* Potentially disconnect and discourage a node based on the contents of a TxValidationState object
*
* @return Returns true if the peer was punished (probably disconnected)
*/
static bool MaybePunishNodeForTx(NodeId nodeid, const TxValidationState& state, const std::string& message = "")
bool PeerManager::MaybePunishNodeForTx(NodeId nodeid, const TxValidationState& state, const std::string& message)
{
switch (state.GetResult()) {
case TxValidationResult::TX_RESULT_UNSET:
Expand Down
8 changes: 8 additions & 0 deletions src/net_processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class CBlockHeader;
class CChainParams;
class CTxMemPool;
class ChainstateManager;
class TxValidationState;

extern RecursiveMutex cs_main;
extern RecursiveMutex g_cs_orphans;
Expand Down Expand Up @@ -98,6 +99,13 @@ class PeerManager final : public CValidationInterface, public NetEventsInterface
bool MaybePunishNodeForBlock(NodeId nodeid, const BlockValidationState& state,
bool via_compact_block, const std::string& message = "");

/**
* Potentially disconnect and discourage a node based on the contents of a TxValidationState object
*
* @return Returns true if the peer was punished (probably disconnected)
*/
bool MaybePunishNodeForTx(NodeId nodeid, const TxValidationState& state, const std::string& message = "");

/** Maybe disconnect a peer and discourage future connections from its address.
*
* @param[in] pnode The node to check.
Expand Down

0 comments on commit 3115e00

Please sign in to comment.