mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-08 11:44:14 +01:00
refactor: Add FlatFileSeq member variables in BlockManager
Instead of constructing a new class every time a file operation is done, construct them once for each of the undo and block file when a new BlockManager is created. In future, this might make it easier to introduce an abstract block store.
This commit is contained in:
@@ -63,7 +63,7 @@ public:
|
||||
fs::path FileName(const FlatFilePos& pos) const;
|
||||
|
||||
/** Open a handle to the file at the given position. */
|
||||
FILE* Open(const FlatFilePos& pos, bool read_only = false);
|
||||
FILE* Open(const FlatFilePos& pos, bool read_only = false) const;
|
||||
|
||||
/**
|
||||
* Allocate additional space in a file after the given starting position. The amount allocated
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
* @param[out] out_of_space Whether the allocation failed due to insufficient disk space.
|
||||
* @return The number of bytes successfully allocated.
|
||||
*/
|
||||
size_t Allocate(const FlatFilePos& pos, size_t add_size, bool& out_of_space);
|
||||
size_t Allocate(const FlatFilePos& pos, size_t add_size, bool& out_of_space) const;
|
||||
|
||||
/**
|
||||
* Commit a file to disk, and optionally truncate off extra pre-allocated bytes if final.
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
* @param[in] finalize True if no more data will be written to this file.
|
||||
* @return true on success, false on failure.
|
||||
*/
|
||||
bool Flush(const FlatFilePos& pos, bool finalize = false);
|
||||
bool Flush(const FlatFilePos& pos, bool finalize = false) const;
|
||||
};
|
||||
|
||||
#endif // BITCOIN_FLATFILE_H
|
||||
|
||||
Reference in New Issue
Block a user