diff options
| author | Suhas Daftuar <[email protected]> | 2015-06-04 13:00:26 -0400 |
|---|---|---|
| committer | Ross Nicoll <[email protected]> | 2015-07-29 18:29:30 +0100 |
| commit | fc1f115ee55e6a4972b88e168e78a6533512076d (patch) | |
| tree | 3d64bb309eabf1290db7b3f1f11a384b70922a79 /src/main.cpp | |
| parent | doc: mention bitcoin-submittx example in release notes (diff) | |
| download | discoin-fc1f115ee55e6a4972b88e168e78a6533512076d.tar.xz discoin-fc1f115ee55e6a4972b88e168e78a6533512076d.zip | |
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.
Github-Pull: #6233
Rebased-From: 3e9143386a90e508c8d41719294db11264f5f0a0
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp index ded32eb03..cd4670254 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -436,13 +436,14 @@ void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vector<CBl // Iterate over those blocks in vToFetch (in forward direction), adding the ones that // are not yet downloaded and not in flight to vBlocks. In the mean time, update - // pindexLastCommonBlock as long as all ancestors are already downloaded. + // pindexLastCommonBlock as long as all ancestors are already downloaded, or if it's + // already part of our chain (and therefore don't need it even if pruned). BOOST_FOREACH(CBlockIndex* pindex, vToFetch) { if (!pindex->IsValid(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) { |