aboutsummaryrefslogtreecommitdiff
path: root/src/node/blockstorage.h
diff options
context:
space:
mode:
authorTheCharlatan <seb.kung@gmail.com>2023-07-25 11:32:09 +0200
committerTheCharlatan <seb.kung@gmail.com>2023-08-31 23:26:44 +0200
commitf0207e00303a1030eca795ede231e3c0d94df061 (patch)
tree128d9440975baa977dfcaf15709957f53cf29641 /src/node/blockstorage.h
parent5671c15f4520c6dc20e0805fd0b06157ff94bcd7 (diff)
downloadbitcoin-f0207e00303a1030eca795ede231e3c0d94df061.tar.xz
blockstorage: Return on fatal block file flush error
By returning an error code if `FlushBlockFile` fails, the caller now has to explicitly handle block file flushing errors. Before this change such errors were non-explicitly ignored without a clear rationale. Prior to this patch `FlushBlockFile` may have failed silently in `Chainstate::FlushStateToDisk`. Improve this with a log line. Also add a TODO comment to flesh out whether returning early in the case of an error is appropriate or not. Returning early might be appropriate to prohibit `WriteBlockIndexDB` from writing a block index entry that does not refer to a fully flushed block. Besides `Chainstate::FlushStateToDisk`, `FlushBlockFile` is also called by `FindBlockPos`. Don't change the abort behavior there, since we don't want to fail the function if the flushing of already written blocks fails. Instead, just document it.
Diffstat (limited to 'src/node/blockstorage.h')
-rw-r--r--src/node/blockstorage.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h
index 0e8b9abce9..3e0962386f 100644
--- a/src/node/blockstorage.h
+++ b/src/node/blockstorage.h
@@ -91,7 +91,10 @@ private:
*/
bool LoadBlockIndex()
EXCLUSIVE_LOCKS_REQUIRED(cs_main);
- void FlushBlockFile(bool fFinalize = false, bool finalize_undo = false);
+
+ /** Return false if block file flushing fails. */
+ [[nodiscard]] bool FlushBlockFile(bool fFinalize = false, bool finalize_undo = false);
+
void FlushUndoFile(int block_file, bool finalize = false);
[[nodiscard]] bool FindBlockPos(FlatFilePos& pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown);
bool FindUndoPos(BlockValidationState& state, int nFile, FlatFilePos& pos, unsigned int nAddSize);