From: CryptoManiac Date: Tue, 19 Aug 2014 22:16:24 +0000 (+0400) Subject: Coins selection fix X-Git-Tag: v0.4.4.6-nvc-update8^2~1^2~3 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=f5875a9a87b3341857381e847703cc4ae4890737 Coins selection fix --- diff --git a/src/kernel.cpp b/src/kernel.cpp index ae686be..18db341 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -392,7 +392,7 @@ bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, unsigned // Scan given coins set for kernel solution bool ScanForStakeKernelHash(CoinsSet &setCoins, MetaMap &mapMeta, KernelSearchSettings &settings, CoinsSet::value_type &kernelcoin, unsigned int &nTimeTx, unsigned int &nBlockTime) { - uint256 hashProofOfStake = 0, targetProofOfStake = 0; + uint256 hashProofOfStake = 0; for(CoinsSet::const_iterator pcoin = setCoins.begin(); pcoin != setCoins.end(); pcoin++) { @@ -436,7 +436,7 @@ bool ScanForStakeKernelHash(CoinsSet &setCoins, MetaMap &mapMeta, KernelSearchSe { nTimeTx = settings.nTime - n; CBigNum bnCoinDayWeight = CBigNum(nValueIn) * GetWeight((int64)pcoin->first->nTime, (int64)nTimeTx) / COIN / (24 * 60 * 60); - targetProofOfStake = (bnCoinDayWeight * bnTargetPerCoinDay).getuint256(); + CBigNum bnTargetProofOfStake = bnCoinDayWeight * bnTargetPerCoinDay; // Build kernel CDataStream ss(SER_GETHASH, 0); @@ -446,7 +446,7 @@ bool ScanForStakeKernelHash(CoinsSet &setCoins, MetaMap &mapMeta, KernelSearchSe // Calculate kernel hash hashProofOfStake = Hash(ss.begin(), ss.end()); - if (bnCoinDayWeight * bnTargetPerCoinDay >= CBigNum(hashProofOfStake)) + if (bnTargetProofOfStake >= CBigNum(hashProofOfStake)) { if (fDebug) printf("nStakeModifier=0x%016"PRI64x", nBlockTime=%u nTxOffset=%u nTxPrevTime=%u nVout=%u nTimeTx=%u hashProofOfStake=%s Success=true\n", diff --git a/src/wallet.cpp b/src/wallet.cpp index 104b162..477c4f3 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1639,7 +1639,7 @@ bool CWallet::GetStakeWeight(const CKeyStore& keystore, uint64& nMinWeight, uint static uint256 hashPrevBlock; // Cache outputs unless best block or wallet transaction set changed - if (!fCoinsDataActual) + if (!fCoinsDataActual || setCoins.size() == 0) { int64 nValueIn = 0; if (!SelectCoinsSimple(nBalance - nReserveBalance, GetAdjustedTime(), nCoinbaseMaturity * 10, setCoins, nValueIn)) @@ -1843,7 +1843,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int { LOCK2(cs_main, cs_wallet); // Cache outputs unless best block or wallet transaction set changed - if (!fCoinsDataActual) + if (!fCoinsDataActual || setCoins.size() == 0) { setCoins.clear(); mapMeta.clear();