From 2372eb3b09c3d1a2df75d6d8b5d712db1b16fa52 Mon Sep 17 00:00:00 2001 From: CryptoManiac Date: Tue, 31 Mar 2015 21:52:12 +0300 Subject: [PATCH] Optimize input scanning Comparison with maximum possible target allows us to prevent some worthless CBigNum operations (up to 72% performance boost). --- src/kernel.cpp | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/kernel.cpp b/src/kernel.cpp index 7429a38..30816d9 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -469,7 +469,7 @@ bool ScanForStakeKernelHash(MetaMap &mapMeta, uint32_t nBits, uint32_t nTime, ui bnTargetPerCoinDay.SetCompact(nBits); int64_t nValueIn = pcoin.first->vout[pcoin.second].nValue; - // Search backward in time from the given timestamp + // Search backward in time from the given timestamp // Search nSearchInterval seconds back up to nMaxStakeSearchInterval // Stopping search in case of shutting down or cache invalidation for (unsigned int n=0; n maxTarget) + continue; + + CBigNum bnCoinDayWeight = CBigNum(nValueIn) * GetWeight((int64_t)tx.nTime, (int64_t)nTimeTx) / COIN / (24 * 60 * 60); + CBigNum bnTargetProofOfStake = bnCoinDayWeight * bnTargetPerCoinDay; + if (bnTargetProofOfStake >= CBigNum(hashProofOfStake)) { solution.first = hashProofOfStake; -- 1.7.1