From 256246a9fa5b05141c93aeeb359394b9c7a80e49 Mon Sep 17 00:00:00 2001 From: Daniela Brozzoni Date: Thu, 5 Jun 2025 13:59:14 +0200 Subject: [PATCH] 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> --- src/net_processing.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 3a712f2f800..7ab70cd63a3 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -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& headers, const Consensus::Params& consensusParams, Peer& peer); + bool CheckHeadersPoW(const std::vector& 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& headers, const Consensus::Params& consensusParams, Peer& peer) +bool PeerManagerImpl::CheckHeadersPoW(const std::vector& 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