From: Sunny King Date: Mon, 9 Jul 2012 18:36:29 +0000 (+0100) Subject: PPCoin: Ask for pending sync-checkpoint block X-Git-Tag: v0.4.0-unstable~132 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=47c304dcf377722321f7e1cbe7aa371725fba258 PPCoin: Ask for pending sync-checkpoint block --- diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 4447414..6c28158 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -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 diff --git a/src/checkpoints.h b/src/checkpoints.h index fd7d432..35cbc65 100644 --- a/src/checkpoints.h +++ b/src/checkpoints.h @@ -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 diff --git a/src/main.cpp b/src/main.cpp index b274071..b09357a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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); }