mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
validation: Refactor file flush logic into FlatFileSeq.
This commit is contained in:
parent
992404b31e
commit
e0380933e3
3 changed files with 33 additions and 18 deletions
|
|
@ -1630,25 +1630,12 @@ void static FlushBlockFile(bool fFinalize = false)
|
|||
{
|
||||
LOCK(cs_LastBlockFile);
|
||||
|
||||
CDiskBlockPos posOld(nLastBlockFile, 0);
|
||||
CDiskBlockPos block_pos_old(nLastBlockFile, vinfoBlockFile[nLastBlockFile].nSize);
|
||||
CDiskBlockPos undo_pos_old(nLastBlockFile, vinfoBlockFile[nLastBlockFile].nUndoSize);
|
||||
|
||||
bool status = true;
|
||||
|
||||
FILE *fileOld = OpenBlockFile(posOld);
|
||||
if (fileOld) {
|
||||
if (fFinalize)
|
||||
status &= TruncateFile(fileOld, vinfoBlockFile[nLastBlockFile].nSize);
|
||||
status &= FileCommit(fileOld);
|
||||
fclose(fileOld);
|
||||
}
|
||||
|
||||
fileOld = OpenUndoFile(posOld);
|
||||
if (fileOld) {
|
||||
if (fFinalize)
|
||||
status &= TruncateFile(fileOld, vinfoBlockFile[nLastBlockFile].nUndoSize);
|
||||
status &= FileCommit(fileOld);
|
||||
fclose(fileOld);
|
||||
}
|
||||
|
||||
status &= BlockFileSeq().Flush(block_pos_old, fFinalize);
|
||||
status &= UndoFileSeq().Flush(undo_pos_old, fFinalize);
|
||||
if (!status) {
|
||||
AbortNode("Flushing block file to disk failed. This is likely the result of an I/O error.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue