| 1675 | } |
| 1676 | |
| 1677 | void 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 | |
| 1705 | static bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigned int nAddSize); |
| 1706 |
no test coverage detected