Add previous block checking in the proof-of-stake miner
[novacoin.git] / src / miner.cpp
index ca5a132..d5ace13 100644 (file)
@@ -166,9 +166,7 @@ CBlock* CreateNewBlock(CWallet* pwallet, bool fProofOfStake)
     int64 nFees = 0;
     {
         LOCK2(cs_main, mempool.cs);
-        CCoinsDB coinsdb("r");
-        CCoinsViewDB viewdb(coinsdb);
-        CCoinsViewCache view(viewdb);
+        CCoinsViewCache view(*pcoinsTip, true);
 
         // Priority order to process transactions
         list<COrphan> vOrphan; // list memory doesn't move
@@ -308,13 +306,16 @@ CBlock* CreateNewBlock(CWallet* pwallet, bool fProofOfStake)
             if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS)
                 continue;
 
+/*
+ * We need to call UpdateCoins using actual block timestamp, so don't perform this here.
+ *
             CTxUndo txundo;
             if (!tx.UpdateCoins(viewTemp, txundo, pindexPrev->nHeight+1, pblock->nTime))
                 continue;
 
             // push changes from the second layer cache to the first one
             viewTemp.Flush();
-
+*/
             // Added
             pblock->vtx.push_back(tx);
             nBlockSize += nTxSize;
@@ -380,7 +381,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&
     }
     ++nExtraNonce;
 
-    unsigned int nHeight = pindexPrev->nHeight+1; // Height first in coinbase required for block.version=2
+    unsigned int nHeight = pindexPrev->nHeight+1; // Height first in coinbase required
     pblock->vtx[0].vin[0].scriptSig = (CScript() << nHeight << CBigNum(nExtraNonce)) + COINBASE_FLAGS;
     assert(pblock->vtx[0].vin[0].scriptSig.size() <= 100);
 
@@ -563,7 +564,5 @@ void StakeMiner(CWallet *pwallet)
         }
         else
             Sleep(nMinerSleep);
-
-        continue;
     }
 }