2016-12-31 10:01:21 -08:00
|
|
|
// Copyright (c) 2009-2016 The Bitcoin Core developers
|
2014-10-30 17:43:19 -07:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2012-05-18 07:02:28 -07:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2011-09-08 13:50:58 -07:00
|
|
|
|
2017-11-09 16:57:53 -08:00
|
|
|
#include <checkpoints.h>
|
2011-09-08 13:50:58 -07:00
|
|
|
|
2017-11-09 16:57:53 -08:00
|
|
|
#include <chain.h>
|
|
|
|
#include <chainparams.h>
|
|
|
|
#include <reverse_iterator.h>
|
|
|
|
#include <validation.h>
|
2012-04-15 13:10:54 -07:00
|
|
|
|
2013-04-12 22:13:08 -07:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
2014-06-24 05:17:43 -07:00
|
|
|
namespace Checkpoints {
|
|
|
|
|
2015-04-22 15:19:11 -07:00
|
|
|
CBlockIndex* GetLastCheckpoint(const CCheckpointData& data)
|
2011-09-08 09:51:43 -07:00
|
|
|
{
|
2015-04-22 15:19:11 -07:00
|
|
|
const MapCheckpoints& checkpoints = data.mapCheckpoints;
|
2011-09-08 09:51:43 -07:00
|
|
|
|
2017-04-12 15:51:39 -07:00
|
|
|
for (const MapCheckpoints::value_type& i : reverse_iterate(checkpoints))
|
2011-09-08 09:51:43 -07:00
|
|
|
{
|
|
|
|
const uint256& hash = i.second;
|
2014-09-03 17:02:44 -07:00
|
|
|
BlockMap::const_iterator t = mapBlockIndex.find(hash);
|
2011-09-08 09:51:43 -07:00
|
|
|
if (t != mapBlockIndex.end())
|
|
|
|
return t->second;
|
|
|
|
}
|
2017-08-06 22:36:37 -07:00
|
|
|
return nullptr;
|
2011-09-08 09:51:43 -07:00
|
|
|
}
|
2014-06-24 05:17:43 -07:00
|
|
|
|
|
|
|
} // namespace Checkpoints
|