refactor: Compute work from headers without CBlockIndex

Avoid the need to construct a CBlockIndex object just to compute work for a header,
when its nBits value suffices for that.

Co-Authored-By: Pieter Wuille <pieter@wuille.net>
This commit is contained in:
Daniela Brozzoni
2025-08-18 11:46:04 +02:00
parent 0bf6139e19
commit 4066bfe561
5 changed files with 16 additions and 9 deletions

View File

@@ -4171,8 +4171,7 @@ arith_uint256 CalculateClaimedHeadersWork(std::span<const CBlockHeader> headers)
{
arith_uint256 total_work{0};
for (const CBlockHeader& header : headers) {
CBlockIndex dummy(header);
total_work += GetBlockProof(dummy);
total_work += GetBlockProof(header);
}
return total_work;
}