|
|
@ -1572,7 +1572,7 @@ bool CBlock::DisconnectBlock(CBlockIndex *pindex, CCoinsViewCache &view, bool *p |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void static FlushBlockFile() |
|
|
|
void static FlushBlockFile(bool fFinalize = false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(cs_LastBlockFile); |
|
|
|
LOCK(cs_LastBlockFile); |
|
|
|
|
|
|
|
|
|
|
@ -1580,12 +1580,16 @@ void static FlushBlockFile() |
|
|
|
|
|
|
|
|
|
|
|
FILE *fileOld = OpenBlockFile(posOld); |
|
|
|
FILE *fileOld = OpenBlockFile(posOld); |
|
|
|
if (fileOld) { |
|
|
|
if (fileOld) { |
|
|
|
|
|
|
|
if (fFinalize) |
|
|
|
|
|
|
|
TruncateFile(fileOld, infoLastBlockFile.nSize); |
|
|
|
FileCommit(fileOld); |
|
|
|
FileCommit(fileOld); |
|
|
|
fclose(fileOld); |
|
|
|
fclose(fileOld); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fileOld = OpenUndoFile(posOld); |
|
|
|
fileOld = OpenUndoFile(posOld); |
|
|
|
if (fileOld) { |
|
|
|
if (fileOld) { |
|
|
|
|
|
|
|
if (fFinalize) |
|
|
|
|
|
|
|
TruncateFile(fileOld, infoLastBlockFile.nUndoSize); |
|
|
|
FileCommit(fileOld); |
|
|
|
FileCommit(fileOld); |
|
|
|
fclose(fileOld); |
|
|
|
fclose(fileOld); |
|
|
|
} |
|
|
|
} |
|
|
@ -1991,7 +1995,7 @@ bool FindBlockPos(CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeigh |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
while (infoLastBlockFile.nSize + nAddSize >= MAX_BLOCKFILE_SIZE) { |
|
|
|
while (infoLastBlockFile.nSize + nAddSize >= MAX_BLOCKFILE_SIZE) { |
|
|
|
printf("Leaving block file %i: %s\n", nLastBlockFile, infoLastBlockFile.ToString().c_str()); |
|
|
|
printf("Leaving block file %i: %s\n", nLastBlockFile, infoLastBlockFile.ToString().c_str()); |
|
|
|
FlushBlockFile(); |
|
|
|
FlushBlockFile(true); |
|
|
|
nLastBlockFile++; |
|
|
|
nLastBlockFile++; |
|
|
|
infoLastBlockFile.SetNull(); |
|
|
|
infoLastBlockFile.SetNull(); |
|
|
|
pblocktree->ReadBlockFileInfo(nLastBlockFile, infoLastBlockFile); // check whether data for the new file somehow already exist; can fail just fine
|
|
|
|
pblocktree->ReadBlockFileInfo(nLastBlockFile, infoLastBlockFile); // check whether data for the new file somehow already exist; can fail just fine
|
|
|
|