PPCoin: Asking for blocks when checkpoint block is not yet accepted
authorScott Nadal <scott.nadal@gmail.com>
Thu, 7 Jun 2012 15:03:01 +0000 (16:03 +0100)
committerScott Nadal <scott.nadal@gmail.com>
Thu, 7 Jun 2012 15:03:01 +0000 (16:03 +0100)
src/checkpoints.cpp
src/checkpoints.h
src/main.cpp

index 4560240..ac86c95 100644 (file)
@@ -62,7 +62,7 @@ namespace Checkpoints
     CSyncCheckpoint checkpointMessagePending;
     CCriticalSection cs_hashSyncCheckpoint;
 
-    bool CSyncCheckpoint::ProcessSyncCheckpoint()
+    bool CSyncCheckpoint::ProcessSyncCheckpoint(CNode* pfrom)
     {
         if (!CheckSignature())
             return false;
@@ -71,8 +71,11 @@ namespace Checkpoints
         {
             if (!mapBlockIndex.count(hashCheckpoint))
             {
-                // TODO: we don't have this block yet, so ask for it
+                // We haven't accepted this block, keep the checkpoint as pending
                 checkpointMessagePending = *this;
+                // Ask this guy to fill in what we're missing
+                if (pfrom)
+                    pfrom->PushGetBlocks(pindexBest, hashCheckpoint);
                 return false;
             }
 
index 6ef2c14..372f32b 100644 (file)
@@ -128,7 +128,7 @@ namespace Checkpoints
             return true;
         }
 
-        bool ProcessSyncCheckpoint();
+        bool ProcessSyncCheckpoint(CNode* pfrom);
     };
 
     extern uint256 hashSyncCheckpoint;
index 0dca0ae..e1bdac6 100644 (file)
@@ -2588,7 +2588,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
         Checkpoints::CSyncCheckpoint checkpoint;
         vRecv >> checkpoint;
 
-        if (checkpoint.ProcessSyncCheckpoint())
+        if (checkpoint.ProcessSyncCheckpoint(pfrom))
         {
             // Relay
             pfrom->hashCheckpointKnown = checkpoint.hashCheckpoint;