aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-06-30 17:12:23 +0200
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-07-26 12:28:59 +0200
commitfa7f7ac040a9467c307b20e77dc47c87d7377ded (patch)
treea8b40dbf215dccb652c91979bc2fa981f1df6bba /src/node
parent1e8d689e01643cf6af5ab049d3296d3df73536e3 (diff)
downloadbitcoin-fa7f7ac040a9467c307b20e77dc47c87d7377ded.tar.xz
Return XOR AutoFile from BlockManager::Open*File()
This is a refactor, because the XOR key is empty.
Diffstat (limited to 'src/node')
-rw-r--r--src/node/blockstorage.cpp12
-rw-r--r--src/node/blockstorage.h9
2 files changed, 13 insertions, 8 deletions
diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp
index 29b624cb12..338452c23f 100644
--- a/src/node/blockstorage.cpp
+++ b/src/node/blockstorage.cpp
@@ -818,13 +818,13 @@ void BlockManager::UnlinkPrunedFiles(const std::set<int>& setFilesToPrune) const
AutoFile BlockManager::OpenBlockFile(const FlatFilePos& pos, bool fReadOnly) const
{
- return AutoFile{m_block_file_seq.Open(pos, fReadOnly)};
+ return AutoFile{m_block_file_seq.Open(pos, fReadOnly), m_xor_key};
}
/** Open an undo file (rev?????.dat) */
AutoFile BlockManager::OpenUndoFile(const FlatFilePos& pos, bool fReadOnly) const
{
- return AutoFile{m_undo_file_seq.Open(pos, fReadOnly)};
+ return AutoFile{m_undo_file_seq.Open(pos, fReadOnly), m_xor_key};
}
fs::path BlockManager::GetBlockPosFilename(const FlatFilePos& pos) const
@@ -1144,6 +1144,14 @@ FlatFilePos BlockManager::SaveBlockToDisk(const CBlock& block, int nHeight)
return blockPos;
}
+BlockManager::BlockManager(const util::SignalInterrupt& interrupt, Options opts)
+ : m_prune_mode{opts.prune_target > 0},
+ m_xor_key{},
+ 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} {}
+
class ImportingNow
{
std::atomic<bool>& m_importing;
diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h
index 8c6190cd02..821bbf5109 100644
--- a/src/node/blockstorage.h
+++ b/src/node/blockstorage.h
@@ -240,6 +240,8 @@ private:
const bool m_prune_mode;
+ const std::vector<std::byte> m_xor_key;
+
/** Dirty block index entries. */
std::set<CBlockIndex*> m_dirty_blockindex;
@@ -264,12 +266,7 @@ private:
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} {}
+ explicit BlockManager(const util::SignalInterrupt& interrupt, Options opts);
const util::SignalInterrupt& m_interrupt;
std::atomic<bool> m_importing{false};