// Copyright (c) 2014-2018 The BlackCoin Developers // Copyright (c) 2011-2013 The PPCoin developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. // Stake cache by Qtum // Copyright (c) 2016-2018 The Qtum developers #ifndef BLACKCOIN_POS_H #define BLACKCOIN_POS_H #include "pos.h" #include "txdb.h" #include "main.h" #include "arith_uint256.h" #include "consensus/validation.h" #include "hash.h" #include "timedata.h" #include "chainparams.h" #include "script/sign.h" #include using namespace std; /** Compute the hash modifier for proof-of-stake */ uint256 ComputeStakeModifier(const CBlockIndex* pindexPrev, const uint256& kernel); struct CStakeCache{ CStakeCache(CBlockHeader blockFrom_, CDiskTxPos txindex_, const CTransaction txPrev_) : blockFrom(blockFrom_), txindex(txindex_), txPrev(txPrev_){ } CBlockHeader blockFrom; CDiskTxPos txindex; const CTransaction txPrev; }; // Check whether the coinstake timestamp meets protocol bool CheckCoinStakeTimestamp(int64_t nTimeBlock, int64_t nTimeTx); bool CheckStakeBlockTimestamp(int64_t nTimeBlock); bool CheckKernel(CBlockIndex* pindexPrev, unsigned int nBits, uint32_t nTime, const COutPoint& prevout, uint32_t* pBlockTime = NULL); bool CheckKernel(CBlockIndex* pindexPrev, unsigned int nBits, uint32_t nTime, const COutPoint& prevout, uint32_t* pBlockTime, const std::map& cache); bool CheckStakeKernelHash(const CBlockIndex* pindexPrev, unsigned int nBits, const CCoins* txPrev, const COutPoint& prevout, unsigned int nTimeTx, bool fPrintProofOfStake = false); bool IsConfirmedInNPrevBlocks(const CDiskTxPos& txindex, const CBlockIndex* pindexFrom, int nMaxDepth, int& nActualDepth); bool CheckProofOfStake(CBlockIndex* pindexPrev, const CTransaction& tx, unsigned int nBits, CValidationState &state); void CacheKernel(std::map& cache, const COutPoint& prevout); bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType); #endif // BLACKCOIN_POS_H