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

Method FindEarliestAtLeast

src/chain.cpp:91–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91CBlockIndex* CChain::FindEarliestAtLeast(int64_t nTime, int height) const
92{
93 std::pair<int64_t, int> blockparams = std::make_pair(nTime, height);
94 std::vector<CBlockIndex*>::const_iterator lower = std::lower_bound(vChain.begin(), vChain.end(), blockparams,
95 [](CBlockIndex* pBlock, const std::pair<int64_t, int>& blockparams) -> bool { return pBlock->GetBlockTimeMax() < blockparams.first || pBlock->nHeight < blockparams.second; });
96 return (lower == vChain.end() ? nullptr : *lower);
97}
98
99/** Turn the lowest '1' bit in the binary representation of a number into a '0'. */
100int static inline InvertLowestOne(int n) { return n & (n - 1); }

Callers 3

BOOST_AUTO_TEST_CASEFunction · 0.80
pruneblockchainFunction · 0.80

Calls 3

GetBlockTimeMaxMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64