From 23dedd96ce1a35aa115a09600ecdcebf52721448 Mon Sep 17 00:00:00 2001 From: svost Date: Fri, 30 Sep 2016 09:33:41 +0300 Subject: [PATCH] Pos mining wake up. Partial revert https://github.com/novacoin-project/novacoin/commit/08e69083634e1c18164e98888f6a65e05757511d#diff-e25a265a6c6826233947a77f534ef48e --- src/kernel_worker.cpp | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/kernel_worker.cpp b/src/kernel_worker.cpp index dc31005..25b73b8 100644 --- a/src/kernel_worker.cpp +++ b/src/kernel_worker.cpp @@ -75,11 +75,13 @@ vector >& KernelWorker::GetSolutions() bool ScanKernelBackward(uint8_t *kernel, uint32_t nBits, uint32_t nInputTxTime, int64_t nValueIn, pair &SearchInterval, pair &solution) { - uint256 nTargetPerCoinDay; - nTargetPerCoinDay.SetCompact(nBits); + CBigNum bnTargetPerCoinDay; + bnTargetPerCoinDay.SetCompact(nBits); + + CBigNum bnValueIn(nValueIn); // Get maximum possible target to filter out the majority of obviously insufficient hashes - auto nMaxTarget = nTargetPerCoinDay * (uint64_t)nValueIn * (uint64_t)nStakeMaxAge / (uint64_t)COIN / (uint64_t)nOneDay; + auto nMaxTarget = (bnTargetPerCoinDay * bnValueIn * nStakeMaxAge / COIN / nOneDay).getuint256(); SHA256_CTX ctx, workerCtx; // Init new sha256 context and update it @@ -108,10 +110,10 @@ bool ScanKernelBackward(uint8_t *kernel, uint32_t nBits, uint32_t nInputTxTime, if (hashProofOfStake > nMaxTarget) continue; - auto nCoinDayWeight = uint256(nValueIn) * (uint64_t)GetWeight((int64_t)nInputTxTime, (int64_t)nTimeTx) / (uint64_t)COIN / (uint64_t)nOneDay; // TODO: Stop using signed types for value, time, weight and so on, because all these casts are really stupid. - auto nTargetProofOfStake = nCoinDayWeight * nTargetPerCoinDay; + auto bnCoinDayWeight = bnValueIn * GetWeight((int64_t)nInputTxTime, (int64_t)nTimeTx) / COIN / nOneDay; + auto bnTargetProofOfStake = bnCoinDayWeight * bnTargetPerCoinDay; - if (nTargetProofOfStake >= hashProofOfStake) + if (bnTargetProofOfStake >= CBigNum(hashProofOfStake)) { solution = { hashProofOfStake, nTimeTx }; return true; -- 1.7.1