mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-11 15:48:05 +00:00
Merge pull request #6948
22e7807
Always flush block and undo when switching to new file (Pieter Wuille)
This commit is contained in:
commit
849a7e6453
11
src/main.cpp
11
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);
|
||||
|
Loading…
Reference in New Issue
Block a user