| 89 | } |
| 90 | |
| 91 | CBlockIndex* 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'. */ |
| 100 | int static inline InvertLowestOne(int n) { return n & (n - 1); } |