PPCoin: Automatic checkpoint
[novacoin.git] / src / checkpoints.h
1 // Copyright (c) 2011 The Bitcoin developers
2 // Copyright (c) 2011 The PPCoin developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
5 #ifndef BITCOIN_CHECKPOINT_H
6 #define  BITCOIN_CHECKPOINT_H
7
8 #include <map>
9 #include "util.h"
10
11 // ppcoin: auto checkpoint min at 1 day; max at 1 week
12 #define AUTO_CHECKPOINT_MIN_SPAN (60 * 60 * 24)
13 #define AUTO_CHECKPOINT_MAX_SPAN (60 * 60 * 24 * 7)
14
15 class uint256;
16 class CBlockIndex;
17
18 //
19 // Block-chain checkpoints are compiled-in sanity checks.
20 // They are updated every release or three.
21 //
22 namespace Checkpoints
23 {
24     extern int nAutoCheckpoint;
25
26     // Returns true if block passes checkpoint checks
27     bool CheckHardened(int nHeight, const uint256& hash);
28     bool CheckAuto(const CBlockIndex *pindex);
29
30     int  GetNextChainCheckpoint(const CBlockIndex *pindex);
31     void AdvanceAutoCheckpoint(int nCheckpoint);
32
33     // Return conservative estimate of total number of blocks, 0 if unknown
34     int GetTotalBlocksEstimate();
35
36     // Returns last CBlockIndex* in mapBlockIndex that is a checkpoint
37     CBlockIndex* GetLastCheckpoint(const std::map<uint256, CBlockIndex*>& mapBlockIndex);
38 }
39
40 #endif