MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / GetBlockProofEquivalentTime

Function GetBlockProofEquivalentTime

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

Source from the content-addressed store, hash-verified

134}
135
136int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::Params& params)
137{
138 arith_uint256 r;
139 int sign = 1;
140 if (to.nChainWork > from.nChainWork) {
141 r = to.nChainWork - from.nChainWork;
142 } else {
143 r = from.nChainWork - to.nChainWork;
144 sign = -1;
145 }
146 r = r * arith_uint256(params.nPowTargetSpacing) / GetBlockProof(tip);
147 if (r.bits() > 63) {
148 return sign * std::numeric_limits<int64_t>::max();
149 }
150 return sign * r.GetLow64();
151}
152
153/** Find the last common ancestor two blocks have.
154 * Both pa and pb must be non-nullptr. */

Callers 3

BlockRequestAllowedFunction · 0.85
ConnectBlockMethod · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 5

arith_uint256Class · 0.85
GetBlockProofFunction · 0.85
maxFunction · 0.85
bitsMethod · 0.80
GetLow64Method · 0.80

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68