Skip to content

Commit 4568652

Browse files
danielabrozzonisipa
andcommitted
refactor: Use std::span in HasValidProofOfWork
Co-Authored-By: Pieter Wuille <[email protected]>
1 parent 4066bfe commit 4568652

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/validation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4130,10 +4130,10 @@ std::vector<unsigned char> ChainstateManager::GenerateCoinbaseCommitment(CBlock&
41304130
return commitment;
41314131
}
41324132

4133-
bool HasValidProofOfWork(const std::vector<CBlockHeader>& headers, const Consensus::Params& consensusParams)
4133+
bool HasValidProofOfWork(std::span<const CBlockHeader> headers, const Consensus::Params& consensusParams)
41344134
{
4135-
return std::all_of(headers.cbegin(), headers.cend(),
4136-
[&](const auto& header) { return CheckProofOfWork(header.GetHash(), header.nBits, consensusParams);});
4135+
return std::ranges::all_of(headers,
4136+
[&](const auto& header) { return CheckProofOfWork(header.GetHash(), header.nBits, consensusParams); });
41374137
}
41384138

41394139
bool IsBlockMutated(const CBlock& block, bool check_witness_root)

src/validation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,8 @@ BlockValidationState TestBlockValidity(
410410
bool check_pow,
411411
bool check_merkle_root) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
412412

413-
/** Check with the proof of work on each blockheader matches the value in nBits */
414-
bool HasValidProofOfWork(const std::vector<CBlockHeader>& headers, const Consensus::Params& consensusParams);
413+
/** Check that the proof of work on each blockheader matches the value in nBits */
414+
bool HasValidProofOfWork(std::span<const CBlockHeader> headers, const Consensus::Params& consensusParams);
415415

416416
/** Check if a block has been mutated (with respect to its merkle root and witness commitments). */
417417
bool IsBlockMutated(const CBlock& block, bool check_witness_root);

0 commit comments

Comments
 (0)