From cb08fdbf78685b55029768524ca867772711c32b Mon Sep 17 00:00:00 2001 From: Pedro Branco Date: Thu, 16 Jun 2016 15:57:48 +0100 Subject: Add importmulti rpc call --- src/chain.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/chain.cpp') diff --git a/src/chain.cpp b/src/chain.cpp index 77e924e70..1e611906d 100644 --- a/src/chain.cpp +++ b/src/chain.cpp @@ -61,6 +61,13 @@ const CBlockIndex *CChain::FindFork(const CBlockIndex *pindex) const { return pindex; } +CBlockIndex* CChain::FindLatestBefore(int64_t nTime) const +{ + std::vector::const_iterator lower = std::lower_bound(vChain.begin(), vChain.end(), nTime, + [](CBlockIndex* pBlock, const int64_t& time) -> bool { return pBlock->GetBlockTime() < time; }); + return (lower == vChain.end() ? NULL : *lower); +} + /** Turn the lowest '1' bit in the binary representation of a number into a '0'. */ int static inline InvertLowestOne(int n) { return n & (n - 1); } -- cgit v1.2.3