Skip to content

Commit eb7cc9f

Browse files
committed
Rename CalculateHeadersWork to CalculateClaimedHeadersWork
1 parent 2b260ea commit eb7cc9f

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/net_processing.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2690,8 +2690,8 @@ bool PeerManagerImpl::IsContinuationOfLowWorkHeadersSync(Peer& peer, CNode& pfro
26902690

26912691
bool PeerManagerImpl::TryLowWorkHeadersSync(Peer& peer, CNode& pfrom, const CBlockIndex* chain_start_header, std::vector<CBlockHeader>& headers)
26922692
{
2693-
// Calculate the total work on this chain.
2694-
arith_uint256 total_work = chain_start_header->nChainWork + CalculateHeadersWork(headers);
2693+
// Calculate the claimed total work on this chain.
2694+
arith_uint256 total_work = chain_start_header->nChainWork + CalculateClaimedHeadersWork(headers);
26952695

26962696
// Our dynamic anti-DoS threshold (minimum work required on a headers chain
26972697
// before we'll store it)
@@ -4424,7 +4424,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
44244424
MaybeSendGetHeaders(pfrom, GetLocator(m_chainman.m_best_header), *peer);
44254425
}
44264426
return;
4427-
} else if (prev_block->nChainWork + CalculateHeadersWork({cmpctblock.header}) < GetAntiDoSWorkThreshold()) {
4427+
} else if (prev_block->nChainWork + CalculateClaimedHeadersWork({cmpctblock.header}) < GetAntiDoSWorkThreshold()) {
44284428
// If we get a low-work header in a compact block, we can ignore it.
44294429
LogPrint(BCLog::NET, "Ignoring low-work compact block from peer %d\n", pfrom.GetId());
44304430
return;
@@ -4744,8 +4744,8 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
47444744
// cs_main in ProcessNewBlock is fine.
47454745
mapBlockSource.emplace(hash, std::make_pair(pfrom.GetId(), true));
47464746

4747-
// Check work on this block against our anti-dos thresholds.
4748-
if (prev_block && prev_block->nChainWork + CalculateHeadersWork({pblock->GetBlockHeader()}) >= GetAntiDoSWorkThreshold()) {
4747+
// Check claimed work on this block against our anti-dos thresholds.
4748+
if (prev_block && prev_block->nChainWork + CalculateClaimedHeadersWork({pblock->GetBlockHeader()}) >= GetAntiDoSWorkThreshold()) {
47494749
min_pow_checked = true;
47504750
}
47514751
}

src/test/fuzz/headerssync.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ FUZZ_TARGET(headers_sync_state, .init = initialize_headers_sync_state_fuzz)
108108

109109
// If we get to redownloading, the presynced headers need
110110
// to have the min amount of work on them.
111-
assert(CalculateHeadersWork(all_headers) >= min_work);
111+
assert(CalculateClaimedHeadersWork(all_headers) >= min_work);
112112
}
113113
}
114114

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3884,7 +3884,7 @@ bool IsBlockMutated(const CBlock& block, bool check_witness_root)
38843884
return false;
38853885
}
38863886

3887-
arith_uint256 CalculateHeadersWork(const std::vector<CBlockHeader>& headers)
3887+
arith_uint256 CalculateClaimedHeadersWork(const std::vector<CBlockHeader>& headers)
38883888
{
38893889
arith_uint256 total_work{0};
38903890
for (const CBlockHeader& header : headers) {

src/validation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ bool HasValidProofOfWork(const std::vector<CBlockHeader>& headers, const Consens
382382
/** Check if a block has been mutated (with respect to its merkle root and witness commitments). */
383383
bool IsBlockMutated(const CBlock& block, bool check_witness_root);
384384

385-
/** Return the sum of the work on a given set of headers */
386-
arith_uint256 CalculateHeadersWork(const std::vector<CBlockHeader>& headers);
385+
/** Return the sum of the claimed work on a given set of headers. No verification of PoW is done. */
386+
arith_uint256 CalculateClaimedHeadersWork(const std::vector<CBlockHeader>& headers);
387387

388388
enum class VerifyDBResult {
389389
SUCCESS,

0 commit comments

Comments
 (0)