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