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

Function GetBlockProofEquivalentTime

src/chain.cpp:135–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 4

BlockRequestAllowedMethod · 0.85
ConnectBlockMethod · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
pow.cppFile · 0.85

Calls 4

GetBlockProofFunction · 0.85
bitsMethod · 0.80
GetLow64Method · 0.80
arith_uint256Class · 0.70

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68