aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorAdam Weiss <adam@signal11.com>2015-06-02 15:24:53 -0400
committerAdam Weiss <adam@signal11.com>2015-06-03 13:25:33 -0400
commitc257a8c9a6397eee40734b235a4fdcb8045aec91 (patch)
treef47e8379f4de867f84e8cfeb2488318761539e59 /src/main.cpp
parentf00b62391b9317bf4c83676520fede1fb4027c43 (diff)
downloadbitcoin-c257a8c9a6397eee40734b235a4fdcb8045aec91.tar.xz
Prune: Support noncontiguous block files
In some corner cases, it may be possible for recent blocks to end up in the same block file as much older blocks. Previously, the pruning code would stop looking for files to remove upon first encountering a file containing a block that cannot be pruned, now it will keep looking for candidate files until the target is met and all other criteria are satisfied. This can result in a noncontiguous set of block files (by number) on disk, which is fine except for during some reindex corner cases, so make reindex preparation smarter such that we keep the data we can actually use and throw away the rest. This allows pruning to work correctly while downloading any blocks needed during the reindex.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index efb7fb3f87..03a4082bba 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3031,9 +3031,9 @@ void FindFilesToPrune(std::set<int>& setFilesToPrune)
if (nCurrentUsage + nBuffer < nPruneTarget) // are we below our target?
break;
- // don't prune files that could have a block within MIN_BLOCKS_TO_KEEP of the main chain's tip
+ // don't prune files that could have a block within MIN_BLOCKS_TO_KEEP of the main chain's tip but keep scanning
if (vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune)
- break;
+ continue;
PruneOneBlockFile(fileNumber);
// Queue up the files for removal