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

Function GetBlockProofEquivalentTime

src/chain.cpp:171–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169}
170
171int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::Params& params)
172{
173 arith_uint256 r;
174 int sign = 1;
175 if (to.nChainWork > from.nChainWork) {
176 r = to.nChainWork - from.nChainWork;
177 } else {
178 r = from.nChainWork - to.nChainWork;
179 sign = -1;
180 }
181 r = r * arith_uint256(params.nPowTargetSpacing) / GetBlockProof(tip);
182 if (r.bits() > 63) {
183 return sign * std::numeric_limits<int64_t>::max();
184 }
185 return sign * int64_t(r.GetLow64());
186}
187
188/** Find the last common ancestor two blocks have.
189 * Both pa and pb must be non-nullptr. */

Callers 4

BlockRequestAllowedMethod · 0.85
ConnectBlockMethod · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
FUZZ_TARGET_INITFunction · 0.85

Calls 4

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

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.68
FUZZ_TARGET_INITFunction · 0.68