Skip to content

Commit

Permalink
Merge pull request #6948
Browse files Browse the repository at this point in the history
22e7807 Always flush block and undo when switching to new file (Pieter Wuille)
  • Loading branch information
laanwj committed Nov 5, 2015
2 parents 3038eb6 + 22e7807 commit 849a7e6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 849a7e6

Please sign in to comment.