]> Git Repo - VerusCoin.git/blobdiff - src/checkpoints.cpp
test
[VerusCoin.git] / src / checkpoints.cpp
index 71579bb309e727408fe56f008b40bc5605e6a6fd..20244861399bf182994c7d24b30cad274b084bef 100644 (file)
 namespace Checkpoints {
 
     /**
-     * How many times we expect transactions after the last checkpoint to
-     * be slower. This number is a compromise, as it can't be accurate for
-     * every system. When reindexing from a fast disk with a slow CPU, it
+     * How many times slower we expect checking transactions after the last
+     * checkpoint to be (from checking signatures, which is skipped up to the
+     * last checkpoint). This number is a compromise, as it can't be accurate
+     * for every system. When reindexing from a fast disk with a slow CPU, it
      * can be up to 20, while when downloading from a slow network with a
      * fast multicore CPU, it won't be much higher than 1.
      */
     static const double SIGCHECK_VERIFICATION_FACTOR = 5.0;
 
-    bool fEnabled = true;
-
-    bool CheckBlock(int nHeight, const uint256& hash)
+    bool CheckBlock(const CCheckpointData& data, int nHeight, const uint256& hash)
     {
-        if (!fEnabled)
-            return true;
-
-        const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints;
+        const MapCheckpoints& checkpoints = data.mapCheckpoints;
 
         MapCheckpoints::const_iterator i = checkpoints.find(nHeight);
         if (i == checkpoints.end()) return true;
@@ -38,7 +34,7 @@ namespace Checkpoints {
     }
 
     //! Guess how far we are in the verification process at the given block index
-    double GuessVerificationProgress(CBlockIndex *pindex, bool fSigchecks) {
+    double GuessVerificationProgress(const CCheckpointData& data, CBlockIndex *pindex, bool fSigchecks) {
         if (pindex==NULL)
             return 0.0;
 
@@ -50,8 +46,6 @@ namespace Checkpoints {
         // Work is defined as: 1.0 per transaction before the last checkpoint, and
         // fSigcheckVerificationFactor per transaction after.
 
-        const CCheckpointData &data = Params().Checkpoints();
-
         if (pindex->nChainTx <= data.nTransactionsLastCheckpoint) {
             double nCheapBefore = pindex->nChainTx;
             double nCheapAfter = data.nTransactionsLastCheckpoint - pindex->nChainTx;
@@ -69,22 +63,19 @@ namespace Checkpoints {
         return fWorkBefore / (fWorkBefore + fWorkAfter);
     }
 
-    int GetTotalBlocksEstimate()
+    int GetTotalBlocksEstimate(const CCheckpointData& data)
     {
-        if (!fEnabled)
-            return 0;
+        const MapCheckpoints& checkpoints = data.mapCheckpoints;
 
-        const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints;
+        if (checkpoints.empty())
+            return 0;
 
         return checkpoints.rbegin()->first;
     }
 
-    CBlockIndex* GetLastCheckpoint()
+    CBlockIndex* GetLastCheckpoint(const CCheckpointData& data)
     {
-        if (!fEnabled)
-            return NULL;
-
-        const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints;
+        const MapCheckpoints& checkpoints = data.mapCheckpoints;
 
         BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, checkpoints)
         {
This page took 0.024493 seconds and 4 git commands to generate.