diff --git a/src/pos.cpp b/src/pos.cpp index 0527e5890..2d80bda4a 100644 --- a/src/pos.cpp +++ b/src/pos.cpp @@ -69,7 +69,7 @@ bool CheckStakeBlockTimestamp(int64_t nTimeBlock) // quantities so as to generate blocks faster, degrading the system back into // a proof-of-work situation. // -bool CheckStakeKernelHash(const CBlockIndex* pindexPrev, unsigned int nBits, const CCoins* txPrev, const COutPoint& prevout, unsigned int nTimeTx) +bool CheckStakeKernelHash(const CBlockIndex* pindexPrev, unsigned int nBits, const CCoins* txPrev, const COutPoint& prevout, unsigned int nTimeTx, bool fPrintProofOfStake) { // Weight int64_t nValueIn = txPrev->vout[prevout.n].nValue; @@ -89,10 +89,26 @@ bool CheckStakeKernelHash(const CBlockIndex* pindexPrev, unsigned int nBits, con uint256 hashProofOfStake = ss.GetHash(); + if (fPrintProofOfStake) + { + LogPrintf("CheckStakeKernelHash() : nStakeModifier=%s txPrev.nTime=%u txPrev.vout.hash=%s txPrev.vout.n=%u nTime=%u hashProof=%s\n", + nStakeModifier.GetHex().c_str(), + txPrev->nTime, prevout.hash.ToString(), prevout.n, nTimeTx, + hashProofOfStake.ToString()); + } + // Now check if proof-of-stake hash meets target protocol if (UintToArith256(hashProofOfStake) / nValueIn > bnTarget) return false; + if (fDebug && !fPrintProofOfStake) + { + LogPrintf("CheckStakeKernelHash() : nStakeModifier=%s txPrev.nTime=%u txPrev.vout.hash=%s txPrev.vout.n=%u nTime=%u hashProof=%s\n", + nStakeModifier.GetHex().c_str(), + txPrev->nTime, prevout.hash.ToString(), prevout.n, nTimeTx, + hashProofOfStake.ToString()); + } + return true; } @@ -141,7 +157,7 @@ bool CheckProofOfStake(CBlockIndex* pindexPrev, const CTransaction& tx, unsigned if (IsConfirmedInNPrevBlocks(txindex, pindexPrev, Params().GetConsensus().nStakeMinConfirmations - 1, nDepth)) return state.DoS(100, error("CheckProofOfStake() : tried to stake at depth %d", nDepth + 1)); - if (!CheckStakeKernelHash(pindexPrev, nBits, new CCoins(txPrev, pindexPrev->nHeight), txin.prevout, tx.nTime)) + if (!CheckStakeKernelHash(pindexPrev, nBits, new CCoins(txPrev, pindexPrev->nHeight), txin.prevout, tx.nTime, fDebug)) return state.DoS(1, error("CheckProofOfStake() : INFO: check kernel failed on coinstake %s", tx.GetHash().ToString())); // may occur during initial download or if behind on block chain sync return true; diff --git a/src/pos.h b/src/pos.h index 454857776..653a304d2 100644 --- a/src/pos.h +++ b/src/pos.h @@ -38,7 +38,7 @@ 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 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);