aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-11-05 23:06:23 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2015-11-05 23:06:34 +0100
commit849a7e645323062878604589df97a1cd75517eb1 (patch)
tree9b484d97beb56c4b1d47b5ee8cf84109680c4b2d /src
parent3038eb63e8a674b4818cb5d5e461f1ccf4b2932f (diff)
parent22e780737db57bcb18b3824eb8158e19a4775cb6 (diff)
Merge pull request #6948
22e7807 Always flush block and undo when switching to new file (Pieter Wuille)
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 0199832f76..9016fe42a0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2542,8 +2542,6 @@ bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAdd
if (!fKnown) {
while (vinfoBlockFile[nFile].nSize + nAddSize >= MAX_BLOCKFILE_SIZE) {
- LogPrintf("Leaving block file %i: %s\n", nFile, vinfoBlockFile[nFile].ToString());
- FlushBlockFile(true);
nFile++;
if (vinfoBlockFile.size() <= nFile) {
vinfoBlockFile.resize(nFile + 1);
@@ -2553,7 +2551,14 @@ bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAdd
pos.nPos = vinfoBlockFile[nFile].nSize;
}
- nLastBlockFile = nFile;
+ if (nFile != nLastBlockFile) {
+ if (!fKnown) {
+ LogPrintf("Leaving block file %i: %s\n", nFile, vinfoBlockFile[nFile].ToString());
+ }
+ FlushBlockFile(!fKnown);
+ nLastBlockFile = nFile;
+ }
+
vinfoBlockFile[nFile].AddBlock(nHeight, nTime);
if (fKnown)
vinfoBlockFile[nFile].nSize = std::max(pos.nPos + nAddSize, vinfoBlockFile[nFile].nSize);