Make sure that new stake modifier meets fixed generation interval.
[novacoin.git] / src / kernel.h
1 // Copyright (c) 2012-2013 The PPCoin developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 #ifndef PPCOIN_KERNEL_H
5 #define PPCOIN_KERNEL_H
6
7 #include "main.h"
8
9 // ChainDB upgrade time
10 extern unsigned int nModifierUpgradeTime;
11
12 // MODIFIER_INTERVAL: time to elapse before new modifier is computed
13 extern unsigned int nModifierInterval;
14
15 // MODIFIER_INTERVAL_RATIO:
16 // ratio of group interval length between the last group and the first group
17 static const int MODIFIER_INTERVAL_RATIO = 3;
18
19 // Whether the given block is subject to new modifier protocol
20 bool IsFixedModifierInterval(unsigned int nTimeBlock);
21
22 // Compute the hash modifier for proof-of-stake
23 bool ComputeNextStakeModifier(const CBlockIndex* pindexCurrent, uint64& nStakeModifier, bool& fGeneratedStakeModifier);
24
25 // Check whether stake kernel meets hash target
26 // Sets hashProofOfStake on success return
27 bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, unsigned int nTxPrevOffset, const CTransaction& txPrev, const COutPoint& prevout, unsigned int nTimeTx, uint256& hashProofOfStake, uint256& targetProofOfStake, bool fPrintProofOfStake=false);
28
29 // Check kernel hash target and coinstake signature
30 // Sets hashProofOfStake on success return
31 bool CheckProofOfStake(const CTransaction& tx, unsigned int nBits, uint256& hashProofOfStake, uint256& targetProofOfStake);
32
33 // Get stake modifier checksum
34 unsigned int GetStakeModifierChecksum(const CBlockIndex* pindex);
35
36 // Check stake modifier hard checkpoints
37 bool CheckStakeModifierCheckpoints(int nHeight, unsigned int nStakeModifierChecksum);
38
39 // Get time weight using supplied timestamps
40 int64 GetWeight(int64 nIntervalBeginning, int64 nIntervalEnd);
41
42 #endif // PPCOIN_KERNEL_H