MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / GetBlockProof

Function GetBlockProof

src/pow.cpp:142–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142arith_uint256 GetBlockProof(const CBlockIndex& block)
143{
144 arith_uint256 bnTarget;
145 bool fNegative;
146 bool fOverflow;
147 bnTarget.SetCompact(block.nBits, &fNegative, &fOverflow);
148 if (fNegative || fOverflow || bnTarget == 0)
149 return 0;
150 // We need to compute 2**256 / (bnTarget+1), but we can't represent 2**256
151 // as it's too large for a arith_uint256. However, as 2**256 is at least as large
152 // as bnTarget+1, it is equal to ((2**256 - bnTarget - 1) / (bnTarget+1)) + 1,
153 // or ~bnTarget / (nTarget+1) + 1.
154 return (~bnTarget / (bnTarget + 1)) + 1;
155}
156
157int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::Params& params)
158{

Callers 6

AddToBlockIndexFunction · 0.85
LoadBlockIndexDBFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls

no outgoing calls

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68