PPCoin: Version number and rename checkpoint related constants
[novacoin.git] / src / checkpoints.cpp
index 14141b3..d004c84 100644 (file)
@@ -22,7 +22,7 @@ namespace Checkpoints
     //
     static MapCheckpoints mapCheckpoints =
         boost::assign::map_list_of
-        ( 0, hashGenesisBlock )
+        ( 0, hashGenesisBlockOfficial )
         ; // ppcoin: no checkpoint yet; to be created in future releases
 
     bool CheckHardened(int nHeight, const uint256& hash)
@@ -188,9 +188,9 @@ namespace Checkpoints
 
     uint256 AutoSelectSyncCheckpoint()
     {
-        // select block roughly 8 hours ago
+        // select a block some time ago
         CBlockIndex *pindex = mapBlockIndex[hashSyncCheckpoint];
-        while (pindex->pnext && pindex->pnext->GetBlockTime() + AUTO_CHECKPOINT_MIN_SPAN <= GetAdjustedTime())
+        while (pindex->pnext && pindex->pnext->GetBlockTime() + CHECKPOINT_MIN_SPAN <= GetAdjustedTime())
             pindex = pindex->pnext;
         return pindex->GetBlockHash();
     }
@@ -265,7 +265,6 @@ namespace Checkpoints
                 hashPendingCheckpoint = hash;
                 checkpointMessagePending.SetNull();
                 printf("ResetSyncCheckpoint: pending for sync-checkpoint %s\n", hashPendingCheckpoint.ToString().c_str());
-                // TODO: when to ask for the checkpoint chain?
             }
 
             BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints)
@@ -283,6 +282,13 @@ namespace Checkpoints
             return false;
         }
     }
+
+    void AskForPendingSyncCheckpoint(CNode* pfrom)
+    {
+        CRITICAL_BLOCK(cs_hashSyncCheckpoint)
+            if (pfrom && hashPendingCheckpoint != 0 && (!mapBlockIndex.count(hashPendingCheckpoint)) && (!mapOrphanBlocks.count(hashPendingCheckpoint)))
+                pfrom->AskFor(CInv(MSG_BLOCK, hashPendingCheckpoint));
+    }
 }
 
 // ppcoin: sync-checkpoint master key