MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / FlushBlockFile

Function FlushBlockFile

src/validation.cpp:1677–1703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1675}
1676
1677void static FlushBlockFile(bool fFinalize = false)
1678{
1679 LOCK(cs_LastBlockFile);
1680
1681 CDiskBlockPos posOld(nLastBlockFile, 0);
1682 bool status = true;
1683
1684 FILE *fileOld = OpenBlockFile(posOld);
1685 if (fileOld) {
1686 if (fFinalize)
1687 status &= TruncateFile(fileOld, vinfoBlockFile[nLastBlockFile].nSize);
1688 status &= FileCommit(fileOld);
1689 fclose(fileOld);
1690 }
1691
1692 fileOld = OpenUndoFile(posOld);
1693 if (fileOld) {
1694 if (fFinalize)
1695 status &= TruncateFile(fileOld, vinfoBlockFile[nLastBlockFile].nUndoSize);
1696 status &= FileCommit(fileOld);
1697 fclose(fileOld);
1698 }
1699
1700 if (!status) {
1701 AbortNode("Flushing block file to disk failed. This is likely the result of an I/O error.");
1702 }
1703}
1704
1705static bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigned int nAddSize);
1706

Callers 2

FlushStateToDiskFunction · 0.85
FindBlockPosFunction · 0.85

Calls 5

OpenBlockFileFunction · 0.85
TruncateFileFunction · 0.85
FileCommitFunction · 0.85
OpenUndoFileFunction · 0.85
AbortNodeFunction · 0.85

Tested by

no test coverage detected