PPCoin: Ask for pending sync-checkpoint block
authorSunny King <sunnyking9999@gmail.com>
Mon, 9 Jul 2012 18:36:29 +0000 (19:36 +0100)
committerSunny King <sunnyking9999@gmail.com>
Mon, 9 Jul 2012 18:36:29 +0000 (19:36 +0100)
src/checkpoints.cpp
src/checkpoints.h
src/main.cpp

index 4447414..6c28158 100644 (file)
@@ -283,6 +283,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
index fd7d432..35cbc65 100644 (file)
@@ -44,6 +44,7 @@ namespace Checkpoints
     bool CheckSync(const uint256& hashBlock, const CBlockIndex* pindexPrev);
     bool WantedByPendingSyncCheckpoint(uint256 hashBlock);
     bool ResetSyncCheckpoint();
+    void AskForPendingSyncCheckpoint(CNode* pfrom);
 }
 
 // ppcoin: synchronized checkpoint
index b274071..b09357a 100644 (file)
@@ -1642,6 +1642,9 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock)
         }
     }
 
+    // ppcoin: ask for pending sync-checkpoint if any
+    if (!IsInitialBlockDownload())
+        Checkpoints::AskForPendingSyncCheckpoint(pfrom);
 
     // If don't already have its previous block, shunt it off to holding area until we get it
     if (!mapBlockIndex.count(pblock->hashPrevBlock))
@@ -2204,6 +2207,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
         printf("version message: version %d, blocks=%d\n", pfrom->nVersion, pfrom->nStartingHeight);
 
         cPeerBlockCounts.input(pfrom->nStartingHeight);
+
+        // ppcoin: ask for pending sync-checkpoint if any
+        if (!IsInitialBlockDownload())
+            Checkpoints::AskForPendingSyncCheckpoint(pfrom);
     }