MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetBlockProof

Function GetBlockProof

src/chain.cpp:151–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151arith_uint256 GetBlockProof(const CBlockIndex& block)
152{
153 // All valid signed blocks have "weight" 1
154 if (g_signed_blocks) {
155 return 1;
156 }
157
158 arith_uint256 bnTarget;
159 bool fNegative;
160 bool fOverflow;
161 bnTarget.SetCompact(block.nBits, &fNegative, &fOverflow);
162 if (fNegative || fOverflow || bnTarget == 0)
163 return 0;
164 // We need to compute 2**256 / (bnTarget+1), but we can't represent 2**256
165 // as it's too large for an arith_uint256. However, as 2**256 is at least as large
166 // as bnTarget+1, it is equal to ((2**256 - bnTarget - 1) / (bnTarget+1)) + 1,
167 // or ~bnTarget / (bnTarget+1) + 1.
168 return (~bnTarget / (bnTarget + 1)) + 1;
169}
170
171int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::Params& params)
172{

Callers 6

BOOST_AUTO_TEST_CASEFunction · 0.85
FUZZ_TARGET_INITFunction · 0.85
AddToBlockIndexMethod · 0.85
LoadBlockIndexMethod · 0.85

Calls

no outgoing calls

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.68
FUZZ_TARGET_INITFunction · 0.68