X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Fkernel.cpp;h=7429a38779a09e432ef325653982469f59b55c3e;hp=4055314749a6bf60d9d75ab872a31c7d688d2241;hb=6fccda8e55816a81e21f89ae54c92785242ee8f8;hpb=1e7993f68d8ada2bf6a523ac3b4afec64157f8ed diff --git a/src/kernel.cpp b/src/kernel.cpp index 4055314..7429a38 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -512,13 +512,10 @@ bool ScanForStakeKernelHash(MetaMap &mapMeta, uint32_t nBits, uint32_t nTime, ui // Scan given input for kernel solution bool ScanInputForStakeKernelHash(CTransaction &tx, uint32_t nOut, uint32_t nBits, uint32_t nSearchInterval, std::pair &solution) { + CTxDB txdb("r"); + CBlock block; CTxIndex txindex; - uint256 hashProofOfStake; - - int nTime = GetTime(); - - CTxDB txdb("r"); // Load transaction index item if (!txdb.ReadTxIndex(tx.GetHash(), txindex)) @@ -532,13 +529,17 @@ bool ScanInputForStakeKernelHash(CTransaction &tx, uint32_t nOut, uint32_t nBits if (!GetKernelStakeModifier(block.GetHash(), nStakeModifier)) return false; + uint32_t nTime = GetTime(); + // Only count coins meeting min age requirement + if (nStakeMinAge + block.nTime > nTime) + nTime += (nStakeMinAge + block.nTime - nTime); + // Transaction offset inside block uint32_t nTxOffset = txindex.pos.nTxPos - txindex.pos.nBlockPos; + int64_t nValueIn = tx.vout[nOut].nValue; - uint32_t nBlockTime = block.nTime; CBigNum bnTargetPerCoinDay; bnTargetPerCoinDay.SetCompact(nBits); - int64_t nValueIn = tx.vout[nOut].nValue; // Search forward in time from the given timestamp // Stopping search in case of shutting down @@ -551,10 +552,10 @@ bool ScanInputForStakeKernelHash(CTransaction &tx, uint32_t nOut, uint32_t nBits // Build kernel CDataStream ss(SER_GETHASH, 0); ss << nStakeModifier; - ss << nBlockTime << nTxOffset << tx.nTime << nOut << nTimeTx; + ss << block.nTime << nTxOffset << tx.nTime << nOut << nTimeTx; // Calculate kernel hash - hashProofOfStake = Hash(ss.begin(), ss.end()); + uint256 hashProofOfStake = Hash(ss.begin(), ss.end()); if (bnTargetProofOfStake >= CBigNum(hashProofOfStake)) {