X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fminer.cpp;h=c03b37d7b17861b957f7d3bed6a458300ec560cd;hb=b551b8a0a3084036528b348622e341bd43ef38e3;hp=02b38bf161352e47919f849a503be5ecf51a0e48;hpb=a348ee6f5081803ad1ae860c29075b08d772dd08;p=novacoin.git diff --git a/src/miner.cpp b/src/miner.cpp index 02b38bf..c03b37d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -289,9 +289,6 @@ CBlock* CreateNewBlock(CWallet* pwallet, CTransaction *txCoinStake) if (tx.nTime > GetAdjustedTime() || (fProofOfStake && tx.nTime > txCoinStake->nTime)) continue; - // Simplify transaction fee - allow free = false - int64_t nMinFee = tx.GetMinFee(nBlockSize, true, GMF_BLOCK, nTxSize); - // Skip free transactions if we're past the minimum block size: if (fSortedByFee && (dFeePerKb < nMinTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) continue; @@ -314,10 +311,13 @@ CBlock* CreateNewBlock(CWallet* pwallet, CTransaction *txCoinStake) if (!tx.FetchInputs(txdb, mapTestPoolTmp, false, true, mapInputs, fInvalid)) continue; + // Transaction fee int64_t nTxFees = tx.GetValueIn(mapInputs)-tx.GetValueOut(); + int64_t nMinFee = tx.GetMinFee(nBlockSize, true, GMF_BLOCK, nTxSize); if (nTxFees < nMinFee) continue; + // Sigops accumulation nTxSigOps += tx.GetP2SHSigOpCount(mapInputs); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) continue; @@ -649,7 +649,8 @@ bool ScanMap(const MidstateMap &inputsMap, uint32_t nBits, MidstateMap::key_type return false; } -void StakeMiner(CWallet *pwallet) +// TODO: Get rid of nested loops +void StakeMiner(CWallet* pwallet) { SetThreadPriority(THREAD_PRIORITY_LOWEST); @@ -710,7 +711,7 @@ void StakeMiner(CWallet *pwallet) CTransaction txCoinStake; // Create new coinstake transaction - if (!pwallet->CreateCoinStake(LuckyInput.first, LuckyInput.second, solution.second, pindexPrev->nBits, txCoinStake, key)) + if (!pwallet->CreateCoinStake(LuckyInput.first, LuckyInput.second, solution.second, nBits, txCoinStake, key)) { string strMessage = _("Warning: Unable to create coinstake transaction, see debug.log for the details. Mining thread has been stopped."); strMiscWarning = strMessage; @@ -769,3 +770,24 @@ void StakeMiner(CWallet *pwallet) continue; } } + +// Stake minter thread +void ThreadStakeMinter(void* parg) +{ + printf("ThreadStakeMinter started\n"); + CWallet* pwallet = (CWallet*)parg; + try + { + vnThreadsRunning[THREAD_MINTER]++; + StakeMiner(pwallet); + vnThreadsRunning[THREAD_MINTER]--; + } + catch (std::exception& e) { + vnThreadsRunning[THREAD_MINTER]--; + PrintException(&e, "ThreadStakeMinter()"); + } catch (...) { + vnThreadsRunning[THREAD_MINTER]--; + PrintException(NULL, "ThreadStakeMinter()"); + } + printf("ThreadStakeMinter exiting, %d threads remaining\n", vnThreadsRunning[THREAD_MINTER]); +}