|
1 | 1 | // Copyright (c) 2011-2013 The PPCoin developers |
2 | 2 | // Copyright (c) 2013-2014 The NovaCoin Developers |
3 | 3 | // Copyright (c) 2014-2018 The BlackCoin Developers |
4 | | -// Copyright (c) 2015-2019 The PIVX developers |
| 4 | +// Copyright (c) 2015-2020 The PIVX developers |
5 | 5 | // Distributed under the MIT/X11 software license, see the accompanying |
6 | 6 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. |
7 | 7 |
|
8 | | -#ifndef BITCOIN_KERNEL_H |
9 | | -#define BITCOIN_KERNEL_H |
| 8 | +#ifndef PIVX_KERNEL_H |
| 9 | +#define PIVX_KERNEL_H |
10 | 10 |
|
11 | 11 | #include "main.h" |
12 | 12 | #include "stakeinput.h" |
13 | 13 |
|
14 | | - |
15 | | -// MODIFIER_INTERVAL: time to elapse before new modifier is computed |
16 | | -static const unsigned int MODIFIER_INTERVAL = 60; |
17 | | - |
18 | | -// MODIFIER_INTERVAL_RATIO: |
19 | | -// ratio of group interval length between the last group and the first group |
20 | | -static const int MODIFIER_INTERVAL_RATIO = 3; |
21 | | - |
22 | | -// Compute the hash modifier for proof-of-stake |
23 | | -bool GetKernelStakeModifier(const uint256& hashBlockFrom, uint64_t& nStakeModifier, int& nStakeModifierHeight, int64_t& nStakeModifierTime, bool fPrintProofOfStake); |
24 | | -bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64_t& nStakeModifier, bool& fGeneratedStakeModifier); |
25 | | -uint256 ComputeStakeModifier(const CBlockIndex* pindexPrev, const uint256& kernel); |
26 | | -bool Stake(const CBlockIndex* pindexPrev, CStakeInput* stakeInput, unsigned int nBits, int64_t& nTimeTx, uint256& hashProofOfStake); |
27 | | - |
| 14 | +/* PoS Validation */ |
| 15 | +bool GetHashProofOfStake(const CBlockIndex* pindexPrev, CStakeInput* stake, const unsigned int nTimeTx, const bool fVerify, uint256& hashProofOfStakeRet); |
| 16 | +bool CheckStakeKernelHash(const CBlockIndex* pindexPrev, const unsigned int nBits, CStakeInput* stake, const unsigned int nTimeTx, uint256& hashProofOfStake, const bool fVerify = false); |
| 17 | +bool CheckProofOfStake(const CBlock& block, uint256& hashProofOfStake, std::unique_ptr<CStakeInput>& stake, int nPreviousBlockHeight); |
28 | 18 | // Initialize the stake input object |
29 | 19 | bool initStakeInput(const CBlock& block, std::unique_ptr<CStakeInput>& stake, int nPreviousBlockHeight); |
| 20 | +// (New) Stake Modifier |
| 21 | +uint256 ComputeStakeModifier(const CBlockIndex* pindexPrev, const uint256& kernel); |
| 22 | +// Stake (find valid kernel) |
| 23 | +bool Stake(const CBlockIndex* pindexPrev, CStakeInput* stakeInput, unsigned int nBits, int64_t& nTimeTx, uint256& hashProofOfStake); |
30 | 24 |
|
31 | | -// Check kernel hash target and coinstake signature |
32 | | -// Sets hashProofOfStake on success return |
33 | | -bool CheckProofOfStake(const CBlock& block, uint256& hashProofOfStake, std::unique_ptr<CStakeInput>& stake, int nPreviousBlockHeight); |
34 | | -bool CheckStakeKernelHash(const CBlockIndex* pindexPrev, const unsigned int nBits, CStakeInput* stake, const unsigned int nTimeTx, uint256& hashProofOfStake, const bool fVerify = false); |
35 | | -// Returns the proof of stake hash |
36 | | -bool GetHashProofOfStake(const CBlockIndex* pindexPrev, CStakeInput* stake, const unsigned int nTimeTx, const bool fVerify, uint256& hashProofOfStakeRet); |
37 | | -// Get stake modifier checksum |
38 | | -unsigned int GetStakeModifierChecksum(const CBlockIndex* pindex); |
39 | | - |
40 | | -// Check stake modifier hard checkpoints |
41 | | -bool CheckStakeModifierCheckpoints(int nHeight, unsigned int nStakeModifierChecksum); |
42 | | - |
| 25 | +/* Utils */ |
43 | 26 | int64_t GetTimeSlot(const int64_t nTime); |
44 | 27 | int64_t GetCurrentTimeSlot(); |
45 | 28 | uint32_t ParseAccChecksum(uint256 nCheckpoint, const libzerocoin::CoinDenomination denom); |
46 | 29 |
|
47 | | -#endif // BITCOIN_KERNEL_H |
| 30 | + |
| 31 | +/* Old Stake Modifier */ |
| 32 | +unsigned int GetStakeModifierChecksum(const CBlockIndex* pindex); |
| 33 | +bool GetOldStakeModifier(CStakeInput* stake, uint64_t& nStakeModifier); |
| 34 | +bool GetOldModifier(const uint256& hashBlockFrom, uint64_t& nStakeModifier); |
| 35 | +bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64_t& nStakeModifier, bool& fGeneratedStakeModifier); |
| 36 | + |
| 37 | +#endif // PIVX_KERNEL_H |
0 commit comments