Skip to content

Commit fa7f7ac

Browse files
author
MarcoFalke
committed
Return XOR AutoFile from BlockManager::Open*File()
This is a refactor, because the XOR key is empty.
1 parent 1e8d689 commit fa7f7ac

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/node/blockstorage.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,13 +818,13 @@ void BlockManager::UnlinkPrunedFiles(const std::set<int>& setFilesToPrune) const
818818

819819
AutoFile BlockManager::OpenBlockFile(const FlatFilePos& pos, bool fReadOnly) const
820820
{
821-
return AutoFile{m_block_file_seq.Open(pos, fReadOnly)};
821+
return AutoFile{m_block_file_seq.Open(pos, fReadOnly), m_xor_key};
822822
}
823823

824824
/** Open an undo file (rev?????.dat) */
825825
AutoFile BlockManager::OpenUndoFile(const FlatFilePos& pos, bool fReadOnly) const
826826
{
827-
return AutoFile{m_undo_file_seq.Open(pos, fReadOnly)};
827+
return AutoFile{m_undo_file_seq.Open(pos, fReadOnly), m_xor_key};
828828
}
829829

830830
fs::path BlockManager::GetBlockPosFilename(const FlatFilePos& pos) const
@@ -1144,6 +1144,14 @@ FlatFilePos BlockManager::SaveBlockToDisk(const CBlock& block, int nHeight)
11441144
return blockPos;
11451145
}
11461146

1147+
BlockManager::BlockManager(const util::SignalInterrupt& interrupt, Options opts)
1148+
: m_prune_mode{opts.prune_target > 0},
1149+
m_xor_key{},
1150+
m_opts{std::move(opts)},
1151+
m_block_file_seq{FlatFileSeq{m_opts.blocks_dir, "blk", m_opts.fast_prune ? 0x4000 /* 16kB */ : BLOCKFILE_CHUNK_SIZE}},
1152+
m_undo_file_seq{FlatFileSeq{m_opts.blocks_dir, "rev", UNDOFILE_CHUNK_SIZE}},
1153+
m_interrupt{interrupt} {}
1154+
11471155
class ImportingNow
11481156
{
11491157
std::atomic<bool>& m_importing;

src/node/blockstorage.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ class BlockManager
240240

241241
const bool m_prune_mode;
242242

243+
const std::vector<std::byte> m_xor_key;
244+
243245
/** Dirty block index entries. */
244246
std::set<CBlockIndex*> m_dirty_blockindex;
245247

@@ -264,12 +266,7 @@ class BlockManager
264266
public:
265267
using Options = kernel::BlockManagerOpts;
266268

267-
explicit BlockManager(const util::SignalInterrupt& interrupt, Options opts)
268-
: m_prune_mode{opts.prune_target > 0},
269-
m_opts{std::move(opts)},
270-
m_block_file_seq{FlatFileSeq{m_opts.blocks_dir, "blk", m_opts.fast_prune ? 0x4000 /* 16kB */ : BLOCKFILE_CHUNK_SIZE}},
271-
m_undo_file_seq{FlatFileSeq{m_opts.blocks_dir, "rev", UNDOFILE_CHUNK_SIZE}},
272-
m_interrupt{interrupt} {}
269+
explicit BlockManager(const util::SignalInterrupt& interrupt, Options opts);
273270

274271
const util::SignalInterrupt& m_interrupt;
275272
std::atomic<bool> m_importing{false};

0 commit comments

Comments
 (0)