Skip to content

Commit 6eecba4

Browse files
committed
net_processing: make MaybePunishNodeFor{Block,Tx} return void
1 parent ae60d48 commit 6eecba4

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/net_processing.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -555,19 +555,15 @@ class PeerManagerImpl final : public PeerManager
555555
* punish peers differently depending on whether the data was provided in a compact
556556
* block message or not. If the compact block had a valid header, but contained invalid
557557
* txs, the peer should not be punished. See BIP 152.
558-
*
559-
* @return Returns true if the peer was punished (probably disconnected)
560558
*/
561-
bool MaybePunishNodeForBlock(NodeId nodeid, const BlockValidationState& state,
559+
void MaybePunishNodeForBlock(NodeId nodeid, const BlockValidationState& state,
562560
bool via_compact_block, const std::string& message = "")
563561
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
564562

565563
/**
566564
* Potentially disconnect and discourage a node based on the contents of a TxValidationState object
567-
*
568-
* @return Returns true if the peer was punished (probably disconnected)
569565
*/
570-
bool MaybePunishNodeForTx(NodeId nodeid, const TxValidationState& state)
566+
void MaybePunishNodeForTx(NodeId nodeid, const TxValidationState& state)
571567
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
572568

573569
/** Maybe disconnect a peer and discourage future connections from its address.
@@ -1889,7 +1885,7 @@ void PeerManagerImpl::Misbehaving(Peer& peer, const std::string& message)
18891885
LogPrint(BCLog::NET, "Misbehaving: peer=%d%s\n", peer.m_id, message_prefixed);
18901886
}
18911887

1892-
bool PeerManagerImpl::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidationState& state,
1888+
void PeerManagerImpl::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidationState& state,
18931889
bool via_compact_block, const std::string& message)
18941890
{
18951891
PeerRef peer{GetPeerRef(nodeid)};
@@ -1905,7 +1901,7 @@ bool PeerManagerImpl::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidati
19051901
case BlockValidationResult::BLOCK_MUTATED:
19061902
if (!via_compact_block) {
19071903
if (peer) Misbehaving(*peer, message);
1908-
return true;
1904+
return;
19091905
}
19101906
break;
19111907
case BlockValidationResult::BLOCK_CACHED_INVALID:
@@ -1920,30 +1916,29 @@ bool PeerManagerImpl::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidati
19201916
// Exempt HB compact block peers. Manual connections are always protected from discouragement.
19211917
if (!via_compact_block && !node_state->m_is_inbound) {
19221918
if (peer) Misbehaving(*peer, message);
1923-
return true;
1919+
return;
19241920
}
19251921
break;
19261922
}
19271923
case BlockValidationResult::BLOCK_INVALID_HEADER:
19281924
case BlockValidationResult::BLOCK_CHECKPOINT:
19291925
case BlockValidationResult::BLOCK_INVALID_PREV:
19301926
if (peer) Misbehaving(*peer, message);
1931-
return true;
1927+
return;
19321928
// Conflicting (but not necessarily invalid) data or different policy:
19331929
case BlockValidationResult::BLOCK_MISSING_PREV:
19341930
if (peer) Misbehaving(*peer, message);
1935-
return true;
1931+
return;
19361932
case BlockValidationResult::BLOCK_RECENT_CONSENSUS_CHANGE:
19371933
case BlockValidationResult::BLOCK_TIME_FUTURE:
19381934
break;
19391935
}
19401936
if (message != "") {
19411937
LogPrint(BCLog::NET, "peer=%d: %s\n", nodeid, message);
19421938
}
1943-
return false;
19441939
}
19451940

1946-
bool PeerManagerImpl::MaybePunishNodeForTx(NodeId nodeid, const TxValidationState& state)
1941+
void PeerManagerImpl::MaybePunishNodeForTx(NodeId nodeid, const TxValidationState& state)
19471942
{
19481943
PeerRef peer{GetPeerRef(nodeid)};
19491944
switch (state.GetResult()) {
@@ -1952,7 +1947,7 @@ bool PeerManagerImpl::MaybePunishNodeForTx(NodeId nodeid, const TxValidationStat
19521947
// The node is providing invalid data:
19531948
case TxValidationResult::TX_CONSENSUS:
19541949
if (peer) Misbehaving(*peer, "");
1955-
return true;
1950+
return;
19561951
// Conflicting (but not necessarily invalid) data or different policy:
19571952
case TxValidationResult::TX_RECENT_CONSENSUS_CHANGE:
19581953
case TxValidationResult::TX_INPUTS_NOT_STANDARD:
@@ -1968,7 +1963,6 @@ bool PeerManagerImpl::MaybePunishNodeForTx(NodeId nodeid, const TxValidationStat
19681963
case TxValidationResult::TX_UNKNOWN:
19691964
break;
19701965
}
1971-
return false;
19721966
}
19731967

19741968
bool PeerManagerImpl::BlockRequestAllowed(const CBlockIndex* pindex)

0 commit comments

Comments
 (0)