refactor: Use std::span in HasValidProofOfWork

Co-Authored-By: Pieter Wuille <pieter@wuille.net>
This commit is contained in:
Daniela BrozzoniandPieter Wuille committed 2025-11-03 03:52:12 +01:00
1 parent 4066bfe561
commit 4568652222
2 files changed
+5 -5

No files matched your search

+3 -3
View File
@@ -4130,10 +4130,10 @@ std::vector<unsigned char> ChainstateManager::GenerateCoinbaseCommitment(CBlock&
return commitment; return commitment;
} }
bool HasValidProofOfWork(const std::vector<CBlockHeader>& headers, const Consensus::Params& consensusParams) bool HasValidProofOfWork(std::span<const CBlockHeader> headers, const Consensus::Params& consensusParams)
{ {
return std::all_of(headers.cbegin(), headers.cend(), return std::ranges::all_of(headers,
[&](const auto& header) { return CheckProofOfWork(header.GetHash(), header.nBits, consensusParams);}); [&](const auto& header) { return CheckProofOfWork(header.GetHash(), header.nBits, consensusParams); });
} }
bool IsBlockMutated(const CBlock& block, bool check_witness_root) bool IsBlockMutated(const CBlock& block, bool check_witness_root)
+2 -2
View File
@@ -410,8 +410,8 @@ BlockValidationState TestBlockValidity(
bool check_pow, bool check_pow,
bool check_merkle_root) EXCLUSIVE_LOCKS_REQUIRED(cs_main); bool check_merkle_root) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
/** Check with the proof of work on each blockheader matches the value in nBits */ /** Check that the proof of work on each blockheader matches the value in nBits */
bool HasValidProofOfWork(const std::vector<CBlockHeader>& headers, const Consensus::Params& consensusParams); bool HasValidProofOfWork(std::span<const CBlockHeader> headers, const Consensus::Params& consensusParams);
/** Check if a block has been mutated (with respect to its merkle root and witness commitments). */ /** Check if a block has been mutated (with respect to its merkle root and witness commitments). */
bool IsBlockMutated(const CBlock& block, bool check_witness_root); bool IsBlockMutated(const CBlock& block, bool check_witness_root);