Skip to content

Commit e12f287

Browse files
committed
net: cleanup newly added PeerManagerImpl::ProcessNewBlock
Addresses some post-merge comments.
1 parent 610151f commit e12f287

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/net_processing.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,8 @@ class PeerManagerImpl final : public PeerManager
491491

492492
void ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic<bool>& interruptMsgProc) EXCLUSIVE_LOCKS_REQUIRED(peer.m_getdata_requests_mutex) LOCKS_EXCLUDED(::cs_main);
493493

494-
void ProcessBlock(CNode& pfrom, const std::shared_ptr<const CBlock>& pblock, bool fForceProcessing);
494+
/** Process a new block. Perform any post-processing housekeeping */
495+
void ProcessBlock(CNode& node, const std::shared_ptr<const CBlock>& block, bool force_processing);
495496

496497
/** Relay map (txid or wtxid -> CTransactionRef) */
497498
typedef std::map<uint256, CTransactionRef> MapRelay;
@@ -2384,15 +2385,15 @@ void PeerManagerImpl::ProcessGetCFCheckPt(CNode& peer, CDataStream& vRecv)
23842385
m_connman.PushMessage(&peer, std::move(msg));
23852386
}
23862387

2387-
void PeerManagerImpl::ProcessBlock(CNode& pfrom, const std::shared_ptr<const CBlock>& pblock, bool fForceProcessing)
2388+
void PeerManagerImpl::ProcessBlock(CNode& node, const std::shared_ptr<const CBlock>& block, bool force_processing)
23882389
{
2389-
bool fNewBlock = false;
2390-
m_chainman.ProcessNewBlock(m_chainparams, pblock, fForceProcessing, &fNewBlock);
2391-
if (fNewBlock) {
2392-
pfrom.nLastBlockTime = GetTime();
2390+
bool new_block{false};
2391+
m_chainman.ProcessNewBlock(m_chainparams, block, force_processing, &new_block);
2392+
if (new_block) {
2393+
node.nLastBlockTime = GetTime();
23932394
} else {
23942395
LOCK(cs_main);
2395-
mapBlockSource.erase(pblock->GetHash());
2396+
mapBlockSource.erase(block->GetHash());
23962397
}
23972398
}
23982399

@@ -3475,7 +3476,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
34753476
LOCK(cs_main);
34763477
mapBlockSource.emplace(pblock->GetHash(), std::make_pair(pfrom.GetId(), false));
34773478
}
3478-
// Setting fForceProcessing to true means that we bypass some of
3479+
// Setting force_processing to true means that we bypass some of
34793480
// our anti-DoS protections in AcceptBlock, which filters
34803481
// unrequested blocks that might be trying to waste our resources
34813482
// (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,
34843485
// we have a chain with at least nMinimumChainWork), and we ignore
34853486
// compact blocks with less work than our tip, it is safe to treat
34863487
// reconstructed compact blocks as having been requested.
3487-
ProcessBlock(pfrom, pblock, /*fForceProcessing=*/true);
3488+
ProcessBlock(pfrom, pblock, /*force_processing=*/true);
34883489
LOCK(cs_main); // hold cs_main for CBlockIndex::IsValid()
34893490
if (pindex->IsValid(BLOCK_VALID_TRANSACTIONS)) {
34903491
// Clear download state for this block, which is in
@@ -3567,7 +3568,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
35673568
// disk-space attacks), but this should be safe due to the
35683569
// protections in the compact block handler -- see related comment
35693570
// in compact block optimistic reconstruction handling.
3570-
ProcessBlock(pfrom, pblock, /*fForceProcessing=*/true);
3571+
ProcessBlock(pfrom, pblock, /*force_processing=*/true);
35713572
}
35723573
return;
35733574
}

0 commit comments

Comments
 (0)