PRCYCoin  2.0.0.7rc1
P2P Digital Currency
kernel.h
Go to the documentation of this file.
1 // Copyright (c) 2012-2013 The PPCoin developers
2 // Copyright (c) 2015-2018 The PIVX developers
3 // Copyright (c) 2018-2020 The DAPS Project developers
4 // Distributed under the MIT/X11 software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 #ifndef BITCOIN_KERNEL_H
7 #define BITCOIN_KERNEL_H
8 
9 #include "main.h"
10 #include "stakeinput.h"
11 
12 
13 // MODIFIER_INTERVAL: time to elapse before new modifier is computed
14 static const unsigned int MODIFIER_INTERVAL = 60;
15 static const unsigned int MODIFIER_INTERVAL_TESTNET = 60;
16 extern unsigned int nModifierInterval;
17 extern unsigned int getIntervalVersion(bool fTestNet);
18 
19 // MODIFIER_INTERVAL_RATIO:
20 // ratio of group interval length between the last group and the first group
21 static const int MODIFIER_INTERVAL_RATIO = 3;
22 
23 // Compute the hash modifier for proof-of-stake
24 bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier, int& nStakeModifierHeight, int64_t& nStakeModifierTime, bool fPrintProofOfStake);
25 bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64_t& nStakeModifier, bool& fGeneratedStakeModifier);
26 
27 // Check whether stake kernel meets hash target
28 // Sets hashProofOfStake on success return
29 bool CheckStake(const CDataStream& ssUniqueID, CAmount nValueIn, const uint64_t nStakeModifier, const uint256& bnTarget, unsigned int nTimeBlockFrom, unsigned int& nTimeTx, uint256& hashProofOfStake);
30 bool stakeTargetHit(const uint256& hashProofOfStake, const int64_t& nValueIn, const uint256& bnTargetPerCoinDay);
31 
32 bool Stake(CStakeInput* stakeInput, unsigned int nBits, unsigned int nTimeBlockFrom, unsigned int& nTimeTx, uint256& hashProofOfStake);
33 
34 // Check kernel hash target and coinstake signature
35 // Sets hashProofOfStake on success return
36 bool CheckProofOfStake(const CBlock block, uint256& hashProofOfStake, std::unique_ptr<CStakeInput>& stake, int nPreviousBlockHeight);
37 
38 // Get stake modifier checksum
39 unsigned int GetStakeModifierChecksum(const CBlockIndex* pindex);
40 
41 // Check stake modifier hard checkpoints
42 bool CheckStakeModifierCheckpoints(int nHeight, unsigned int nStakeModifierChecksum);
43 
44 // Get time weight using supplied timestamps
45 int64_t GetWeight(int64_t nIntervalBeginning, int64_t nIntervalEnd);
46 
47 #endif // BITCOIN_KERNEL_H
GetWeight
int64_t GetWeight(int64_t nIntervalBeginning, int64_t nIntervalEnd)
Definition: kernel.cpp:37
CheckStakeModifierCheckpoints
bool CheckStakeModifierCheckpoints(int nHeight, unsigned int nStakeModifierChecksum)
Definition: kernel.cpp:433
CheckStake
bool CheckStake(const CDataStream &ssUniqueID, CAmount nValueIn, const uint64_t nStakeModifier, const uint256 &bnTarget, unsigned int nTimeBlockFrom, unsigned int &nTimeTx, uint256 &hashProofOfStake)
Definition: kernel.cpp:289
nModifierInterval
unsigned int nModifierInterval
Definition: kernel.cpp:22
CStakeInput
Definition: stakeinput.h:16
GetStakeModifierChecksum
unsigned int GetStakeModifierChecksum(const CBlockIndex *pindex)
Definition: kernel.cpp:419
GetKernelStakeModifier
bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t &nStakeModifier, int &nStakeModifierHeight, int64_t &nStakeModifierTime, bool fPrintProofOfStake)
Definition: kernel.cpp:245
CAmount
int64_t CAmount
Amount in PRCY (Can be negative)
Definition: amount.h:17
CheckProofOfStake
bool CheckProofOfStake(const CBlock block, uint256 &hashProofOfStake, std::unique_ptr< CStakeInput > &stake, int nPreviousBlockHeight)
Definition: kernel.cpp:351
uint256
256-bit unsigned big integer.
Definition: uint256.h:38
ComputeNextStakeModifier
bool ComputeNextStakeModifier(const CBlockIndex *pindexPrev, uint64_t &nStakeModifier, bool &fGeneratedStakeModifier)
Definition: kernel.cpp:150
Stake
bool Stake(CStakeInput *stakeInput, unsigned int nBits, unsigned int nTimeBlockFrom, unsigned int &nTimeTx, uint256 &hashProofOfStake)
Definition: kernel.cpp:301
stakeinput.h
CBlock
Definition: block.h:142
main.h
fTestNet
bool fTestNet
Definition: kernel.cpp:18
stakeTargetHit
bool stakeTargetHit(const uint256 &hashProofOfStake, const int64_t &nValueIn, const uint256 &bnTargetPerCoinDay)
Definition: kernel.cpp:280
CDataStream
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:34
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:162
getIntervalVersion
unsigned int getIntervalVersion(bool fTestNet)
Definition: kernel.cpp:24