@@ -555,19 +555,15 @@ class PeerManagerImpl final : public PeerManager
555
555
* punish peers differently depending on whether the data was provided in a compact
556
556
* block message or not. If the compact block had a valid header, but contained invalid
557
557
* txs, the peer should not be punished. See BIP 152.
558
- *
559
- * @return Returns true if the peer was punished (probably disconnected)
560
558
*/
561
- bool MaybePunishNodeForBlock (NodeId nodeid, const BlockValidationState& state,
559
+ void MaybePunishNodeForBlock (NodeId nodeid, const BlockValidationState& state,
562
560
bool via_compact_block, const std::string& message = " " )
563
561
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
564
562
565
563
/* *
566
564
* 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)
569
565
*/
570
- bool MaybePunishNodeForTx (NodeId nodeid, const TxValidationState& state)
566
+ void MaybePunishNodeForTx (NodeId nodeid, const TxValidationState& state)
571
567
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
572
568
573
569
/* * Maybe disconnect a peer and discourage future connections from its address.
@@ -1889,7 +1885,7 @@ void PeerManagerImpl::Misbehaving(Peer& peer, const std::string& message)
1889
1885
LogPrint (BCLog::NET, " Misbehaving: peer=%d%s\n " , peer.m_id , message_prefixed);
1890
1886
}
1891
1887
1892
- bool PeerManagerImpl::MaybePunishNodeForBlock (NodeId nodeid, const BlockValidationState& state,
1888
+ void PeerManagerImpl::MaybePunishNodeForBlock (NodeId nodeid, const BlockValidationState& state,
1893
1889
bool via_compact_block, const std::string& message)
1894
1890
{
1895
1891
PeerRef peer{GetPeerRef (nodeid)};
@@ -1905,7 +1901,7 @@ bool PeerManagerImpl::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidati
1905
1901
case BlockValidationResult::BLOCK_MUTATED:
1906
1902
if (!via_compact_block) {
1907
1903
if (peer) Misbehaving (*peer, message);
1908
- return true ;
1904
+ return ;
1909
1905
}
1910
1906
break ;
1911
1907
case BlockValidationResult::BLOCK_CACHED_INVALID:
@@ -1920,30 +1916,29 @@ bool PeerManagerImpl::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidati
1920
1916
// Exempt HB compact block peers. Manual connections are always protected from discouragement.
1921
1917
if (!via_compact_block && !node_state->m_is_inbound ) {
1922
1918
if (peer) Misbehaving (*peer, message);
1923
- return true ;
1919
+ return ;
1924
1920
}
1925
1921
break ;
1926
1922
}
1927
1923
case BlockValidationResult::BLOCK_INVALID_HEADER:
1928
1924
case BlockValidationResult::BLOCK_CHECKPOINT:
1929
1925
case BlockValidationResult::BLOCK_INVALID_PREV:
1930
1926
if (peer) Misbehaving (*peer, message);
1931
- return true ;
1927
+ return ;
1932
1928
// Conflicting (but not necessarily invalid) data or different policy:
1933
1929
case BlockValidationResult::BLOCK_MISSING_PREV:
1934
1930
if (peer) Misbehaving (*peer, message);
1935
- return true ;
1931
+ return ;
1936
1932
case BlockValidationResult::BLOCK_RECENT_CONSENSUS_CHANGE:
1937
1933
case BlockValidationResult::BLOCK_TIME_FUTURE:
1938
1934
break ;
1939
1935
}
1940
1936
if (message != " " ) {
1941
1937
LogPrint (BCLog::NET, " peer=%d: %s\n " , nodeid, message);
1942
1938
}
1943
- return false ;
1944
1939
}
1945
1940
1946
- bool PeerManagerImpl::MaybePunishNodeForTx (NodeId nodeid, const TxValidationState& state)
1941
+ void PeerManagerImpl::MaybePunishNodeForTx (NodeId nodeid, const TxValidationState& state)
1947
1942
{
1948
1943
PeerRef peer{GetPeerRef (nodeid)};
1949
1944
switch (state.GetResult ()) {
@@ -1952,7 +1947,7 @@ bool PeerManagerImpl::MaybePunishNodeForTx(NodeId nodeid, const TxValidationStat
1952
1947
// The node is providing invalid data:
1953
1948
case TxValidationResult::TX_CONSENSUS:
1954
1949
if (peer) Misbehaving (*peer, " " );
1955
- return true ;
1950
+ return ;
1956
1951
// Conflicting (but not necessarily invalid) data or different policy:
1957
1952
case TxValidationResult::TX_RECENT_CONSENSUS_CHANGE:
1958
1953
case TxValidationResult::TX_INPUTS_NOT_STANDARD:
@@ -1968,7 +1963,6 @@ bool PeerManagerImpl::MaybePunishNodeForTx(NodeId nodeid, const TxValidationStat
1968
1963
case TxValidationResult::TX_UNKNOWN:
1969
1964
break ;
1970
1965
}
1971
- return false ;
1972
1966
}
1973
1967
1974
1968
bool PeerManagerImpl::BlockRequestAllowed (const CBlockIndex* pindex)
0 commit comments