Replace -nosynccheckpoints with a new -cppolicy=mode option
[novacoin.git] / src / main.cpp
index 332832e..4f6d71f 100644 (file)
@@ -75,6 +75,7 @@ const string strMessageMagic = "NovaCoin Signed Message:\n";
 // Settings
 int64 nTransactionFee = MIN_TX_FEE;
 bool fStakeUsePooledKeys = false;
+extern enum Checkpoints::CPMode CheckpointsMode;
 
 //////////////////////////////////////////////////////////////////////////////
 //
@@ -2256,10 +2257,15 @@ bool CBlock::AcceptBlock()
     if (!Checkpoints::CheckHardened(nHeight, hash))
         return DoS(100, error("AcceptBlock() : rejected by hardened checkpoint lock-in at %d", nHeight));
 
+    bool cpSatisfies = Checkpoints::CheckSync(hash, pindexPrev);
+
     // Check that the block satisfies synchronized checkpoint
-    if (!GetBoolArg("-nosynccheckpoints", false) && !Checkpoints::CheckSync(hash, pindexPrev))
+    if (CheckpointsMode == Checkpoints::STRICT && !cpSatisfies)
         return error("AcceptBlock() : rejected by synchronized checkpoint");
 
+    if (CheckpointsMode == Checkpoints::ADVISORY && !cpSatisfies)
+        strMiscWarning = _("WARNING: syncronized checkpoint violation detected, but skipped!");
+
     // Enforce rule that the coinbase starts with serialized block height
     CScript expect = CScript() << nHeight;
     if (vtx[0].vin[0].scriptSig.size() < expect.size() ||
@@ -2964,18 +2970,19 @@ string GetWarnings(string strFor)
 
     // * Should not enter safe mode for longer invalid chain
     // * If sync-checkpoint is too old do not enter safe mode
-    // * Do not display warning if -nosynccheckpoints specified
-    if (!GetBoolArg("-nosynccheckpoints", false) && Checkpoints::IsSyncCheckpointTooOld(60 * 60 * 24 * 10) && !fTestNet && !IsInitialBlockDownload())
+    // * Display warning only in the STRICT mode
+    if (CheckpointsMode == Checkpoints::STRICT && Checkpoints::IsSyncCheckpointTooOld(60 * 60 * 24 * 10) &&
+        !fTestNet && !IsInitialBlockDownload())
     {
         nPriority = 100;
-        strStatusBar = "WARNING: Checkpoint is too old. Wait for block chain to download, or notify developers.";
+        strStatusBar = _("WARNING: Checkpoint is too old. Wait for block chain to download, or notify developers.");
     }
 
     // ppcoin: if detected invalid checkpoint enter safe mode
     if (Checkpoints::hashInvalidCheckpoint != 0)
     {
         nPriority = 3000;
-        strStatusBar = strRPC = "WARNING: Invalid checkpoint found! Displayed transactions may not be correct! You may need to upgrade, or notify developers.";
+        strStatusBar = strRPC = _("WARNING: Invalid checkpoint found! Displayed transactions may not be correct! You may need to upgrade, or notify developers.");
     }
 
     // Alerts