Check block signature only if there are no suitable checkpoints.
authorMASM fan <masmfan@gmail.com>
Sun, 11 Jan 2015 18:42:08 +0000 (10:42 -0800)
committerMASM fan <masmfan@gmail.com>
Sun, 11 Jan 2015 18:42:08 +0000 (10:42 -0800)
Compare block timestamp with timestamp of last checkpoint before running block signature checkings. We don't need block signature checking if this block is older than last hardened checkpoint.

src/checkpoints.cpp
src/checkpoints.h
src/main.cpp

index 747b234..b79db3f 100644 (file)
@@ -52,7 +52,7 @@ namespace Checkpoints
         return checkpoints.rbegin()->first;
     }
 
-    int GetLastCheckpointTime()
+    unsigned int GetLastCheckpointTime()
     {
         MapCheckpoints& checkpoints = (fTestNet ? mapCheckpointsTestnet : mapCheckpoints);
 
index 8d1f2f0..135838d 100644 (file)
@@ -46,7 +46,7 @@ namespace Checkpoints
     CBlockIndex* GetLastCheckpoint(const std::map<uint256, CBlockIndex*>& mapBlockIndex);
 
     // Returns last checkpoint timestamp
-    int GetLastCheckpointTime();
+    unsigned int GetLastCheckpointTime();
 
     extern uint256 hashSyncCheckpoint;
     extern CSyncCheckpoint checkpointMessage;
index 008f209..c366651 100644 (file)
@@ -2312,7 +2312,6 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig) c
     if (fCheckMerkleRoot && hashMerkleRoot != BuildMerkleTree())
         return DoS(100, error("CheckBlock() : hashMerkleRoot mismatch"));
 
-
     return true;
 }
 
@@ -2500,7 +2499,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock)
         return error("ProcessBlock() : duplicate proof-of-stake (%s, %d) for block %s", pblock->GetProofOfStake().first.ToString().c_str(), pblock->GetProofOfStake().second, hash.ToString().c_str());
 
     // Preliminary checks
-    if (!pblock->CheckBlock())
+    if (!pblock->CheckBlock(true, true, (pblock->nTime > Checkpoints::GetLastCheckpointTime())))
         return error("ProcessBlock() : CheckBlock FAILED");
 
     // ppcoin: verify hash target and signature of coinstake tx