PPCoin: Force asking for orphan block's parent block
[novacoin.git] / src / main.cpp
index 4de69bf..4e27d4b 100644 (file)
@@ -1125,7 +1125,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex)
     return true;
 }
 
-bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
+bool Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
 {
     printf("REORGANIZE\n");
 
@@ -1579,8 +1579,8 @@ bool CBlock::AcceptBlock()
         return DoS(100, error("AcceptBlock() : rejected by automatic checkpoint at %d", Checkpoints::nAutoCheckpoint));
 
     // ppcoin: check that the block satisfies synchronized checkpoint
-    if (!Checkpoints::CheckSync(nHeight, hash))
-        return DoS(100, error("AcceptBlock() : rejected by synchronized checkpoint"));
+    if (!Checkpoints::CheckSync(hash, pindexPrev))
+        return error("AcceptBlock() : rejected by synchronized checkpoint");
 
     // Write block to history file
     if (!CheckDiskSpace(::GetSerializeSize(*this, SER_DISK)))
@@ -1674,7 +1674,13 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock)
 
         // Ask this guy to fill in what we're missing
         if (pfrom)
+        {
             pfrom->PushGetBlocks(pindexBest, GetOrphanRoot(pblock2));
+            // ppcoin: getblocks may not obtain the parent block rejected earlier
+            // by duplicate-stake check so we must ask for it again directly
+            if (!mapOrphanBlocks.count(pblock->hashPrevBlock))
+                pfrom->AskFor(CInv(MSG_BLOCK, pblock->hashPrevBlock));
+        }
         return true;
     }