refactor: Remove redundant parameter from CheckHeadersPoW

No need to pass consensusParams, as CheckHeadersPoW already has access
to m_chainparams.GetConsensus()

Co-Authored-By: maflcko <6399679+maflcko@users.noreply.github.com>
This commit is contained in:
Daniela Brozzoni
2025-06-05 13:59:14 +02:00
parent ca0243e3a6
commit 256246a9fa

View File

@@ -644,7 +644,7 @@ private:
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_headers_presync_mutex, g_msgproc_mutex);
/** Various helpers for headers processing, invoked by ProcessHeadersMessage() */
/** Return true if headers are continuous and have valid proof-of-work (DoS points assigned on failure) */
bool CheckHeadersPoW(const std::vector<CBlockHeader>& headers, const Consensus::Params& consensusParams, Peer& peer);
bool CheckHeadersPoW(const std::vector<CBlockHeader>& headers, Peer& peer);
/** Calculate an anti-DoS work threshold for headers chains */
arith_uint256 GetAntiDoSWorkThreshold();
/** Deal with state tracking and headers sync for peers that send
@@ -2485,10 +2485,10 @@ void PeerManagerImpl::SendBlockTransactions(CNode& pfrom, Peer& peer, const CBlo
MakeAndPushMessage(pfrom, NetMsgType::BLOCKTXN, resp);
}
bool PeerManagerImpl::CheckHeadersPoW(const std::vector<CBlockHeader>& headers, const Consensus::Params& consensusParams, Peer& peer)
bool PeerManagerImpl::CheckHeadersPoW(const std::vector<CBlockHeader>& headers, Peer& peer)
{
// Do these headers have proof-of-work matching what's claimed?
if (!HasValidProofOfWork(headers, consensusParams)) {
if (!HasValidProofOfWork(headers, m_chainparams.GetConsensus())) {
Misbehaving(peer, "header with invalid proof of work");
return false;
}
@@ -2853,7 +2853,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer,
// We'll rely on headers having valid proof-of-work further down, as an
// anti-DoS criteria (note: this check is required before passing any
// headers into HeadersSyncState).
if (!CheckHeadersPoW(headers, m_chainparams.GetConsensus(), peer)) {
if (!CheckHeadersPoW(headers, peer)) {
// Misbehaving() calls are handled within CheckHeadersPoW(), so we can
// just return. (Note that even if a header is announced via compact
// block, the header itself should be valid, so this type of error can