mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
refactor, blockstorage: Replace blocksdir arg
Add a blocks_dir field to the BlockManager options. Move functions relying on the global gArgs to get the blocks_dir into the BlockManager class. This should eventually allow users of the BlockManager to not rely on the global Args and instead pass in their own options.
This commit is contained in:
@@ -427,8 +427,7 @@ void BlockManager::CleanupBlockRevFiles() const
|
||||
// Remove the rev files immediately and insert the blk file paths into an
|
||||
// ordered map keyed by block file index.
|
||||
LogPrintf("Removing unusable blk?????.dat and rev?????.dat files for -reindex with -prune\n");
|
||||
const fs::path& blocksdir = gArgs.GetBlocksDirPath();
|
||||
for (fs::directory_iterator it(blocksdir); it != fs::directory_iterator(); it++) {
|
||||
for (fs::directory_iterator it(m_opts.blocks_dir); it != fs::directory_iterator(); it++) {
|
||||
const std::string path = fs::PathToString(it->path().filename());
|
||||
if (fs::is_regular_file(*it) &&
|
||||
path.length() == 12 &&
|
||||
@@ -581,12 +580,12 @@ void BlockManager::UnlinkPrunedFiles(const std::set<int>& setFilesToPrune) const
|
||||
|
||||
FlatFileSeq BlockManager::BlockFileSeq() const
|
||||
{
|
||||
return FlatFileSeq(gArgs.GetBlocksDirPath(), "blk", m_opts.fast_prune ? 0x4000 /* 16kb */ : BLOCKFILE_CHUNK_SIZE);
|
||||
return FlatFileSeq(m_opts.blocks_dir, "blk", m_opts.fast_prune ? 0x4000 /* 16kb */ : BLOCKFILE_CHUNK_SIZE);
|
||||
}
|
||||
|
||||
FlatFileSeq BlockManager::UndoFileSeq() const
|
||||
{
|
||||
return FlatFileSeq(gArgs.GetBlocksDirPath(), "rev", UNDOFILE_CHUNK_SIZE);
|
||||
return FlatFileSeq(m_opts.blocks_dir, "rev", UNDOFILE_CHUNK_SIZE);
|
||||
}
|
||||
|
||||
FILE* BlockManager::OpenBlockFile(const FlatFilePos& pos, bool fReadOnly) const
|
||||
|
||||
Reference in New Issue
Block a user