From 3e9143386a90e508c8d41719294db11264f5f0a0 Mon Sep 17 00:00:00 2001 From: Suhas Daftuar Date: Thu, 4 Jun 2015 13:00:26 -0400 Subject: [PATCH] Advance pindexLastCommonBlock for blocks in chainActive This prevents an edge case where a block downloaded and pruned in-between successive calls to FindNextBlocksToDownload could cause the block to be unnecessarily re-requested. --- src/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 760cda5de..dc9585b02 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -433,13 +433,14 @@ void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vectorIsValid(BLOCK_VALID_TREE)) { // We consider the chain that this peer is on invalid. return; } - if (pindex->nStatus & BLOCK_HAVE_DATA) { + if (pindex->nStatus & BLOCK_HAVE_DATA || chainActive.Contains(pindex)) { if (pindex->nChainTx) state->pindexLastCommonBlock = pindex; } else if (mapBlocksInFlight.count(pindex->GetBlockHash()) == 0) {