aboutsummaryrefslogtreecommitdiff
path: root/src/node/blockstorage.h
diff options
context:
space:
mode:
authorTheCharlatan <seb.kung@gmail.com>2024-07-23 22:18:15 +0200
committerTheCharlatan <seb.kung@gmail.com>2024-07-24 09:39:35 +0200
commit7aa8994c6fceae5cf8fb7e661371cdb19d2cb482 (patch)
tree954e69d64c0b9bedbf77a50088c9be41b7f10190 /src/node/blockstorage.h
parent910d38b22f575cba9a3325de3f4c5ac667d4a487 (diff)
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.
Diffstat (limited to 'src/node/blockstorage.h')
-rw-r--r--src/node/blockstorage.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h
index a946b4ea94..8c6190cd02 100644
--- a/src/node/blockstorage.h
+++ b/src/node/blockstorage.h
@@ -166,9 +166,6 @@ private:
[[nodiscard]] bool FlushChainstateBlockFile(int tip_height);
bool FindUndoPos(BlockValidationState& state, int nFile, FlatFilePos& pos, unsigned int nAddSize);
- FlatFileSeq BlockFileSeq() const;
- FlatFileSeq UndoFileSeq() const;
-
AutoFile OpenUndoFile(const FlatFilePos& pos, bool fReadOnly = false) const;
/**
@@ -261,12 +258,17 @@ private:
const kernel::BlockManagerOpts m_opts;
+ const FlatFileSeq m_block_file_seq;
+ const FlatFileSeq m_undo_file_seq;
+
public:
using Options = kernel::BlockManagerOpts;
explicit BlockManager(const util::SignalInterrupt& interrupt, Options opts)
: m_prune_mode{opts.prune_target > 0},
m_opts{std::move(opts)},
+ m_block_file_seq{FlatFileSeq{m_opts.blocks_dir, "blk", m_opts.fast_prune ? 0x4000 /* 16kB */ : BLOCKFILE_CHUNK_SIZE}},
+ m_undo_file_seq{FlatFileSeq{m_opts.blocks_dir, "rev", UNDOFILE_CHUNK_SIZE}},
m_interrupt{interrupt} {}
const util::SignalInterrupt& m_interrupt;