-
Notifications
You must be signed in to change notification settings - Fork 172
/
checkpoints.cpp
35 lines (29 loc) · 1.08 KB
/
checkpoints.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or https://opensource.org/licenses/mit-license.php.
#include <boost/range/adaptor/reversed.hpp>
#include "chainparams.h"
#include "checkpoints.h"
#include "uint256.h"
namespace Checkpoints
{
bool CheckHardened(int nHeight, const uint256& hash)
{
const MapCheckpoints& checkpoints = Params().Checkpoints().mapCheckpoints;
MapCheckpoints::const_iterator i = checkpoints.find(nHeight);
if (i == checkpoints.end()) return true;
return hash == i->second;
}
CBlockIndex* GetLastCheckpoint(const BlockMap& mapBlockIndex)
{
const MapCheckpoints& checkpoints = Params().Checkpoints().mapCheckpoints;
for (auto const& i : boost::adaptors::reverse(checkpoints))
{
const uint256& hash = i.second;
BlockMap::const_iterator t = mapBlockIndex.find(hash);
if (t != mapBlockIndex.end())
return t->second;
}
return nullptr;
}
}