PPCoin: Automatically select a checkpoint for 'sendcheckpoint'
[novacoin.git] / src / checkpoints.cpp
index 4afdab9..097dd87 100644 (file)
@@ -109,6 +109,15 @@ namespace Checkpoints
         return false;
     }
 
+    uint256 AutoSelectSyncCheckpoint()
+    {
+        // select block roughly 8 hours ago
+        CBlockIndex *pindex = mapBlockIndex[hashSyncCheckpoint];
+        while (pindex->pnext && pindex->pnext->GetBlockTime() + AUTO_CHECKPOINT_MIN_SPAN <= GetAdjustedTime())
+            pindex = pindex->pnext;
+        return pindex->GetBlockHash();
+    }
+
     // ppcoin: automatic checkpoint (represented by height of checkpoint)
     int nAutoCheckpoint = 0;
     int nBranchPoint = 0;    // branch point to alternative branch