mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-29 18:20:58 +02:00
net: cleanup newly added PeerManagerImpl::ProcessNewBlock
Addresses some post-merge comments.
This commit is contained in:
@ -491,7 +491,8 @@ private:
|
|||||||
|
|
||||||
void ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic<bool>& interruptMsgProc) EXCLUSIVE_LOCKS_REQUIRED(peer.m_getdata_requests_mutex) LOCKS_EXCLUDED(::cs_main);
|
void ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic<bool>& interruptMsgProc) EXCLUSIVE_LOCKS_REQUIRED(peer.m_getdata_requests_mutex) LOCKS_EXCLUDED(::cs_main);
|
||||||
|
|
||||||
void ProcessBlock(CNode& pfrom, const std::shared_ptr<const CBlock>& pblock, bool fForceProcessing);
|
/** Process a new block. Perform any post-processing housekeeping */
|
||||||
|
void ProcessBlock(CNode& node, const std::shared_ptr<const CBlock>& block, bool force_processing);
|
||||||
|
|
||||||
/** Relay map (txid or wtxid -> CTransactionRef) */
|
/** Relay map (txid or wtxid -> CTransactionRef) */
|
||||||
typedef std::map<uint256, CTransactionRef> MapRelay;
|
typedef std::map<uint256, CTransactionRef> MapRelay;
|
||||||
@ -2384,15 +2385,15 @@ void PeerManagerImpl::ProcessGetCFCheckPt(CNode& peer, CDataStream& vRecv)
|
|||||||
m_connman.PushMessage(&peer, std::move(msg));
|
m_connman.PushMessage(&peer, std::move(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerManagerImpl::ProcessBlock(CNode& pfrom, const std::shared_ptr<const CBlock>& pblock, bool fForceProcessing)
|
void PeerManagerImpl::ProcessBlock(CNode& node, const std::shared_ptr<const CBlock>& block, bool force_processing)
|
||||||
{
|
{
|
||||||
bool fNewBlock = false;
|
bool new_block{false};
|
||||||
m_chainman.ProcessNewBlock(m_chainparams, pblock, fForceProcessing, &fNewBlock);
|
m_chainman.ProcessNewBlock(m_chainparams, block, force_processing, &new_block);
|
||||||
if (fNewBlock) {
|
if (new_block) {
|
||||||
pfrom.nLastBlockTime = GetTime();
|
node.nLastBlockTime = GetTime();
|
||||||
} else {
|
} else {
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
mapBlockSource.erase(pblock->GetHash());
|
mapBlockSource.erase(block->GetHash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3475,7 +3476,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
|||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
mapBlockSource.emplace(pblock->GetHash(), std::make_pair(pfrom.GetId(), false));
|
mapBlockSource.emplace(pblock->GetHash(), std::make_pair(pfrom.GetId(), false));
|
||||||
}
|
}
|
||||||
// Setting fForceProcessing to true means that we bypass some of
|
// Setting force_processing to true means that we bypass some of
|
||||||
// our anti-DoS protections in AcceptBlock, which filters
|
// our anti-DoS protections in AcceptBlock, which filters
|
||||||
// unrequested blocks that might be trying to waste our resources
|
// unrequested blocks that might be trying to waste our resources
|
||||||
// (eg disk space). Because we only try to reconstruct blocks when
|
// (eg disk space). Because we only try to reconstruct blocks when
|
||||||
@ -3484,7 +3485,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
|||||||
// we have a chain with at least nMinimumChainWork), and we ignore
|
// we have a chain with at least nMinimumChainWork), and we ignore
|
||||||
// compact blocks with less work than our tip, it is safe to treat
|
// compact blocks with less work than our tip, it is safe to treat
|
||||||
// reconstructed compact blocks as having been requested.
|
// reconstructed compact blocks as having been requested.
|
||||||
ProcessBlock(pfrom, pblock, /*fForceProcessing=*/true);
|
ProcessBlock(pfrom, pblock, /*force_processing=*/true);
|
||||||
LOCK(cs_main); // hold cs_main for CBlockIndex::IsValid()
|
LOCK(cs_main); // hold cs_main for CBlockIndex::IsValid()
|
||||||
if (pindex->IsValid(BLOCK_VALID_TRANSACTIONS)) {
|
if (pindex->IsValid(BLOCK_VALID_TRANSACTIONS)) {
|
||||||
// Clear download state for this block, which is in
|
// Clear download state for this block, which is in
|
||||||
@ -3567,7 +3568,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
|||||||
// disk-space attacks), but this should be safe due to the
|
// disk-space attacks), but this should be safe due to the
|
||||||
// protections in the compact block handler -- see related comment
|
// protections in the compact block handler -- see related comment
|
||||||
// in compact block optimistic reconstruction handling.
|
// in compact block optimistic reconstruction handling.
|
||||||
ProcessBlock(pfrom, pblock, /*fForceProcessing=*/true);
|
ProcessBlock(pfrom, pblock, /*force_processing=*/true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user