Add Hurricane Electric and SixXs servers.
[novacoin.git] / src / miner.cpp
index 4f0130a..f12376a 100644 (file)
@@ -17,6 +17,7 @@ using namespace std;
 
 int64_t nReserveBalance = 0;
 static unsigned int nMaxStakeSearchInterval = 60;
+uint64_t nStakeInputsMapSize = 0;
 
 int static FormatHashBlocks(void* pbuffer, unsigned int len)
 {
@@ -288,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;
@@ -313,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;
@@ -600,8 +601,10 @@ bool FillMap(CWallet *pwallet, uint32_t nUpperTime, MidstateMap &inputsMap)
             inputsMap[key] = make_pair(ctx, make_pair(pcoin->first->nTime, pcoin->first->vout[pcoin->second].nValue));
         }
 
+        nStakeInputsMapSize = inputsMap.size();
+
         if (fDebug)
-            printf("Stake miner: %" PRIszu " precalculated contexts created\n", inputsMap.size());
+            printf("Stake miner: map of %" PRIu64 " precalculated contexts has been created\n", nStakeInputsMapSize);
     }
 
     return true;
@@ -707,7 +710,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;