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

Method FindEarliestAtLeast

src/chain.cpp:60–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60CBlockIndex* CChain::FindEarliestAtLeast(int64_t nTime, int height) const
61{
62 std::pair<int64_t, int> blockparams = std::make_pair(nTime, height);
63 std::vector<CBlockIndex*>::const_iterator lower = std::lower_bound(vChain.begin(), vChain.end(), blockparams,
64 [](CBlockIndex* pBlock, const std::pair<int64_t, int>& blockparams) -> bool { return pBlock->GetBlockTimeMax() < blockparams.first || pBlock->nHeight < blockparams.second; });
65 return (lower == vChain.end() ? nullptr : *lower);
66}
67
68/** Turn the lowest '1' bit in the binary representation of a number into a '0'. */
69int 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