Skip to content

Commit

Permalink
net: have ProcessBlock return if block is new
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjors committed Nov 28, 2023
1 parent 516b547 commit 386febd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,15 @@ class PeerManagerImpl final : public PeerManager
EXCLUSIVE_LOCKS_REQUIRED(!m_most_recent_block_mutex, peer.m_getdata_requests_mutex, NetEventsInterface::g_msgproc_mutex)
LOCKS_EXCLUDED(::cs_main);

/** Process a new block. Perform any post-processing housekeeping */
void ProcessBlock(CNode& node, const std::shared_ptr<const CBlock>& block, bool force_processing, bool min_pow_checked);
/** Process a new block. Perform any post-processing housekeeping
* @param[in] node The peer that we received the block from
* @param[in] block The block
* @param[in] force_processing Bypass some of our anti-DoS protections
* @param[in] min_pow_checked The header is known to be part of a
* sufficiently high-work chain (anti-dos check)
* @return True if this is a new block
*/
bool ProcessBlock(CNode& node, const std::shared_ptr<const CBlock>& block, bool force_processing, bool min_pow_checked);

/** Process compact block txns */
void ProcessCompactBlockTxns(CNode& pfrom, Peer& peer, const BlockTransactions& block_transactions)
Expand Down Expand Up @@ -3246,7 +3253,7 @@ void PeerManagerImpl::ProcessGetCFCheckPt(CNode& node, Peer& peer, DataStream& v
headers);
}

void PeerManagerImpl::ProcessBlock(CNode& node, const std::shared_ptr<const CBlock>& block, bool force_processing, bool min_pow_checked)
bool PeerManagerImpl::ProcessBlock(CNode& node, const std::shared_ptr<const CBlock>& block, bool force_processing, bool min_pow_checked)
{
bool new_block{false};
m_chainman.ProcessNewBlock(block, force_processing, min_pow_checked, &new_block);
Expand All @@ -3261,6 +3268,7 @@ void PeerManagerImpl::ProcessBlock(CNode& node, const std::shared_ptr<const CBlo
LOCK(cs_main);
mapBlockSource.erase(block->GetHash());
}
return new_block;
}

void PeerManagerImpl::ProcessCompactBlockTxns(CNode& pfrom, Peer& peer, const BlockTransactions& block_transactions)
Expand Down

0 comments on commit 386febd

Please sign in to comment.