mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Always flush block and undo when switching to new file
Previously, the undo weren't being flushed during a reindex because fKnown was set to true in FindBlockPos. That is the correct behaviour for block files as they aren't being touched, but undo files are touched. This changes the behaviour to always flush when switching to a new file (even for block files, though that isn't really necessary).
This commit is contained in:
parent
193f7b553e
commit
22e780737d
11
src/main.cpp
11
src/main.cpp
@ -2517,8 +2517,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);
|
||||
@ -2528,7 +2526,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