| 58 | } |
| 59 | |
| 60 | CBlockIndex* 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'. */ |
| 69 | int static inline InvertLowestOne(int n) { return n & (n - 1); } |