BSHA3  0.17.99
P2P Blockchain, based on Bitcoin
checkpoints.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009-2018 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <checkpoints.h>
6 
7 #include <chain.h>
8 #include <chainparams.h>
9 #include <reverse_iterator.h>
10 #include <validation.h>
11 
12 #include <stdint.h>
13 
14 
15 namespace Checkpoints {
16 
18  {
19  const MapCheckpoints& checkpoints = data.mapCheckpoints;
20 
21  for (const MapCheckpoints::value_type& i : reverse_iterate(checkpoints))
22  {
23  const uint256& hash = i.second;
24  CBlockIndex* pindex = LookupBlockIndex(hash);
25  if (pindex) {
26  return pindex;
27  }
28  }
29  return nullptr;
30  }
31 
32 } // namespace Checkpoints
std::map< int, uint256 > MapCheckpoints
Definition: chainparams.h:22
reverse_range< T > reverse_iterate(T &x)
Block-chain checkpoints are compiled-in sanity checks.
Definition: checkpoints.cpp:15
CBlockIndex * GetLastCheckpoint(const CCheckpointData &data)
Returns last CBlockIndex* that is a checkpoint.
Definition: checkpoints.cpp:17
256-bit opaque blob.
Definition: uint256.h:122
MapCheckpoints mapCheckpoints
Definition: chainparams.h:25
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:170
CBlockIndex * LookupBlockIndex(const uint256 &hash)
Definition: validation.h:431