LCOV - code coverage report
Current view: top level - src - kernel.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 1 1 100.0 %
Date: 2025-02-23 09:33:43 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright (c) 2011-2013 The PPCoin developers
       2             : // Copyright (c) 2013-2014 The NovaCoin Developers
       3             : // Copyright (c) 2014-2018 The BlackCoin Developers
       4             : // Copyright (c) 2015-2020 The PIVX Core developers
       5             : // Distributed under the MIT/X11 software license, see the accompanying
       6             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       7             : 
       8             : #ifndef PIVX_KERNEL_H
       9             : #define PIVX_KERNEL_H
      10             : 
      11             : #include "stakeinput.h"
      12             : 
      13       19490 : class CStakeKernel {
      14             : public:
      15             :     /**
      16             :      * CStakeKernel Constructor
      17             :      *
      18             :      * @param[in]   pindexPrev      index of the parent of the kernel block
      19             :      * @param[in]   stakeInput      input for the coinstake of the kernel block
      20             :      * @param[in]   nBits           target difficulty bits of the kernel block
      21             :      * @param[in]   nTimeTx         time of the kernel block
      22             :      */
      23             :     CStakeKernel(const CBlockIndex* const pindexPrev, CStakeInput* stakeInput, unsigned int nBits, int nTimeTx);
      24             : 
      25             :     // Return stake kernel hash
      26             :     uint256 GetHash() const;
      27             : 
      28             :     // Check that the kernel hash meets the target required
      29             :     bool CheckKernelHash(bool fSkipLog = false) const;
      30             : 
      31             : private:
      32             :     // kernel message hashed
      33             :     CDataStream stakeModifier{CDataStream(SER_GETHASH, 0)};
      34             :     int nTimeBlockFrom{0};
      35             :     CDataStream stakeUniqueness{CDataStream(SER_GETHASH, 0)};
      36             :     int nTime{0};
      37             :     // hash target
      38             :     unsigned int nBits{0};     // difficulty for the target
      39             :     CAmount stakeValue{0};     // target multiplier
      40             : };
      41             : 
      42             : /* PoS Validation */
      43             : 
      44             : /*
      45             :  * Stake                Check if stakeInput can stake a block on top of pindexPrev
      46             :  *
      47             :  * @param[in]   pindexPrev      index of the parent block of the block being staked
      48             :  * @param[in]   stakeInput      input for the coinstake
      49             :  * @param[in]   nBits           target difficulty bits
      50             :  * @param[in]   nTimeTx         new blocktime
      51             :  * @return      bool            true if stake kernel hash meets target protocol
      52             :  */
      53             : bool Stake(const CBlockIndex* pindexPrev, CStakeInput* stakeInput, unsigned int nBits, int64_t& nTimeTx);
      54             : 
      55             : /*
      56             :  * CheckProofOfStake    Check if block has valid proof of stake
      57             :  *
      58             :  * @param[in]   block           block with the proof being verified
      59             :  * @param[out]  strError        string returning error message (if any, else empty)
      60             :  * @param[in]   pindexPrev      index of the parent block
      61             :  *                              (if nullptr, it will be searched in mapBlockIndex)
      62             :  * @return      bool            true if the block has a valid proof of stake
      63             :  */
      64             : bool CheckProofOfStake(const CBlock& block, std::string& strError, const CBlockIndex* pindexPrev = nullptr);
      65             : 
      66             : /*
      67             :  * GetStakeKernelHash   Return stake kernel of a block
      68             :  *
      69             :  * @param[out]  hashRet         hash of the kernel (set by this function)
      70             :  * @param[in]   block           block with the kernel to return
      71             :  * @param[in]   pindexPrev      index of the parent block
      72             :  *                              (if nullptr, it will be searched in mapBlockIndex)
      73             :  * @return      bool            false if kernel cannot be initialized, true otherwise
      74             :  */
      75             : bool GetStakeKernelHash(uint256& hashRet, const CBlock& block, const CBlockIndex* pindexPrev = nullptr);
      76             : 
      77             : #endif // PIVX_KERNEL_H

Generated by: LCOV version 1.14