diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-11-05 23:06:23 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-11-05 23:06:34 +0100 |
commit | 849a7e645323062878604589df97a1cd75517eb1 (patch) | |
tree | 9b484d97beb56c4b1d47b5ee8cf84109680c4b2d | |
parent | 3038eb63e8a674b4818cb5d5e461f1ccf4b2932f (diff) | |
parent | 22e780737db57bcb18b3824eb8158e19a4775cb6 (diff) |
Merge pull request #6948
22e7807 Always flush block and undo when switching to new file (Pieter Wuille)
-rw-r--r-- | src/main.cpp | 11 |
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); |