mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-04 12:09:26 +01:00
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:
@@ -124,12 +124,12 @@ void CBlockIndex::BuildSkip()
|
||||
pskip = pprev->GetAncestor(GetSkipHeight(nHeight));
|
||||
}
|
||||
|
||||
arith_uint256 GetBlockProof(const CBlockIndex& block)
|
||||
arith_uint256 GetBitsProof(uint32_t bits)
|
||||
{
|
||||
arith_uint256 bnTarget;
|
||||
bool fNegative;
|
||||
bool fOverflow;
|
||||
bnTarget.SetCompact(block.nBits, &fNegative, &fOverflow);
|
||||
bnTarget.SetCompact(bits, &fNegative, &fOverflow);
|
||||
if (fNegative || fOverflow || bnTarget == 0)
|
||||
return 0;
|
||||
// We need to compute 2**256 / (bnTarget+1), but we can't represent 2**256
|
||||
|
||||
Reference in New Issue
Block a user