mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +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:
@@ -30,7 +30,7 @@ fs::path FlatFileSeq::FileName(const FlatFilePos& pos) const
|
||||
return m_dir / fs::u8path(strprintf("%s%05u.dat", m_prefix, pos.nFile));
|
||||
}
|
||||
|
||||
FILE* FlatFileSeq::Open(const FlatFilePos& pos, bool read_only)
|
||||
FILE* FlatFileSeq::Open(const FlatFilePos& pos, bool read_only) const
|
||||
{
|
||||
if (pos.IsNull()) {
|
||||
return nullptr;
|
||||
@@ -52,7 +52,7 @@ FILE* FlatFileSeq::Open(const FlatFilePos& pos, bool read_only)
|
||||
return file;
|
||||
}
|
||||
|
||||
size_t FlatFileSeq::Allocate(const FlatFilePos& pos, size_t add_size, bool& out_of_space)
|
||||
size_t FlatFileSeq::Allocate(const FlatFilePos& pos, size_t add_size, bool& out_of_space) const
|
||||
{
|
||||
out_of_space = false;
|
||||
|
||||
@@ -78,7 +78,7 @@ size_t FlatFileSeq::Allocate(const FlatFilePos& pos, size_t add_size, bool& out_
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool FlatFileSeq::Flush(const FlatFilePos& pos, bool finalize)
|
||||
bool FlatFileSeq::Flush(const FlatFilePos& pos, bool finalize) const
|
||||
{
|
||||
FILE* file = Open(FlatFilePos(pos.nFile, 0)); // Avoid fseek to nPos
|
||||
if (!file) {
|
||||
|
||||
Reference in New Issue
Block a user