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

Method GetMedianTimePast

src/chain.h:372–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370 static constexpr int nMedianTimeSpan = 11;
371
372 int64_t GetMedianTimePast() const
373 {
374 int64_t pmedian[nMedianTimeSpan];
375 int64_t* pbegin = &pmedian[nMedianTimeSpan];
376 int64_t* pend = &pmedian[nMedianTimeSpan];
377
378 const CBlockIndex* pindex = this;
379 for (int i = 0; i < nMedianTimeSpan && pindex; i++, pindex = pindex->pprev)
380 *(--pbegin) = pindex->GetBlockTime();
381
382 std::sort(pbegin, pend);
383 return pbegin[(pend - pbegin) / 2];
384 }
385
386 std::string ToString() const
387 {

Callers 15

CheckFinalTxFunction · 0.80
EXCLUSIVE_LOCKS_REQUIREDFunction · 0.80
ContextualCheckBlockFunction · 0.80
GetBIP9TimeFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
MockTimeFunction · 0.80
FUZZ_TARGETFunction · 0.80
FUZZ_TARGET_INITFunction · 0.80
PrepareBlockFunction · 0.80
getblocktemplateFunction · 0.80

Calls 1

GetBlockTimeMethod · 0.45

Tested by 7

BOOST_AUTO_TEST_CASEFunction · 0.64
BOOST_AUTO_TEST_CASEFunction · 0.64
BOOST_AUTO_TEST_CASEFunction · 0.64
MockTimeFunction · 0.64
FUZZ_TARGETFunction · 0.64
FUZZ_TARGET_INITFunction · 0.64
PrepareBlockFunction · 0.64