]> Git Repo - VerusCoin.git/commitdiff
Fix incorrect validations of block transactions
authormiketout <[email protected]>
Mon, 7 May 2018 17:29:43 +0000 (10:29 -0700)
committermiketout <[email protected]>
Mon, 7 May 2018 17:29:43 +0000 (10:29 -0700)
src/coins.h
src/main.cpp
src/miner.cpp

index fcc32caaed02f66d7cfc120a144b0ca91178d862..85cb69d5c13ec69ca82f485563ddffb9a77c6ced 100644 (file)
@@ -267,6 +267,14 @@ public:
         }
         return ret;
     }
+
+    int64_t TotalTxValue() const {
+        int64_t total = 0;
+        BOOST_FOREACH(const CTxOut &out, vout) {
+            total += out.nValue;
+        }
+        return total;
+    }
 };
 
 class CCoinsKeyHasher
index fb93012255d5d10ba393ab3c8c1ab7745ad31b3b..7a8d2c2b108bd11c06989f144e3b5188a74f9d1b 100644 (file)
@@ -2057,9 +2057,9 @@ namespace Consensus {
                                          REJECT_INVALID, "bad-txns-premature-spend-of-coinbase");
                 }
 
-                // ensure that zeroth output of coinbases are not still time locked
-                uint64_t unlockTime = tx.UnlockTime(0);
-                if (nSpendHeight >= unlockTime) {
+                // ensure that output of coinbases are not still time locked
+                uint64_t unlockTime = komodo_block_unlocktime(coins->nHeight);
+                if (nSpendHeight < unlockTime && coins->TotalTxValue() >= ASSETCHAINS_TIMELOCKGTE) {
                     return state.Invalid(
                                          error("CheckInputs(): tried to spend coinbase that is timelocked until block %d", unlockTime),
                                          REJECT_INVALID, "bad-txns-premature-spend-of-coinbase");
@@ -2563,17 +2563,20 @@ void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const
     const int FIFTY_YEARS = 50*365*24*60*60;
     double alertThreshold = 1.0 / (FIFTY_YEARS / SPAN_SECONDS);
     
-    if (p <= alertThreshold && nBlocks < BLOCKS_EXPECTED)
+    if (bestHeader->nHeight > BLOCKS_EXPECTED)
     {
-        // Many fewer blocks than expected: alert!
-        strWarning = strprintf(_("WARNING: check your network connection, %d blocks received in the last %d hours (%d expected)"),
-                               nBlocks, SPAN_HOURS, BLOCKS_EXPECTED);
-    }
-    else if (p <= alertThreshold && nBlocks > BLOCKS_EXPECTED)
-    {
-        // Many more blocks than expected: alert!
-        strWarning = strprintf(_("WARNING: abnormally high number of blocks generated, %d blocks received in the last %d hours (%d expected)"),
-                               nBlocks, SPAN_HOURS, BLOCKS_EXPECTED);
+        if (p <= alertThreshold && nBlocks < BLOCKS_EXPECTED)
+        {
+            // Many fewer blocks than expected: alert!
+            strWarning = strprintf(_("WARNING: check your network connection, %d blocks received in the last %d hours (%d expected)"),
+                                nBlocks, SPAN_HOURS, BLOCKS_EXPECTED);
+        }
+        else if (p <= alertThreshold && nBlocks > BLOCKS_EXPECTED)
+        {
+            // Many more blocks than expected: alert!
+            strWarning = strprintf(_("WARNING: abnormally high number of blocks generated, %d blocks received in the last %d hours (%d expected)"),
+                                nBlocks, SPAN_HOURS, BLOCKS_EXPECTED);
+        }
     }
     if (!strWarning.empty())
     {
index 7f05d6009e201147dbf52fc70dda3a86008871fb..6df7482c67bb1440b90a5c984e336df0a29f1960 100644 (file)
@@ -792,21 +792,9 @@ void static BitcoinMiner_noeq()
         fprintf(stderr,"Mining %s with %s\n", ASSETCHAINS_SYMBOL, ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO]);
         while (true)
         {
-            if (chainparams.MiningRequiresPeers())
-            {
-                miningTimer.stop();
-                do {
-                    bool fvNodesEmpty;
-                    {
-                        LOCK(cs_vNodes);
-                        fvNodesEmpty = vNodes.empty();
-                    }
-                    if (!fvNodesEmpty )
-                        break;
-                    MilliSleep(1000);
-                } while (true);
-                miningTimer.start();
-            }
+            miningTimer.stop();
+            waitForPeers(chainparams);
+            miningTimer.start();
 
             // Create new block
             unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
This page took 0.059592 seconds and 4 git commands to generate.