mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
refactor, blockstorage: Replace stopafterblockimport arg
Add a stop_after_block_import field to the BlockManager options. Use this field instead of the global gArgs. This should allow users of the BlockManager to not rely on the global Args.
This commit is contained in:
@@ -32,6 +32,7 @@ std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& args, BlockM
|
||||
opts.prune_target = nPruneTarget;
|
||||
|
||||
if (auto value{args.GetBoolArg("-fastprune")}) opts.fast_prune = *value;
|
||||
if (auto value{args.GetBoolArg("-stopafterblockimport")}) opts.stop_after_block_import = *value;
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <chain.h>
|
||||
#include <clientversion.h>
|
||||
#include <common/args.h>
|
||||
#include <consensus/validation.h>
|
||||
#include <flatfile.h>
|
||||
#include <hash.h>
|
||||
@@ -867,7 +866,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFiles, const ArgsManager& args, const fs::path& mempool_path)
|
||||
void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFiles, const fs::path& mempool_path)
|
||||
{
|
||||
SetSyscallSandboxPolicy(SyscallSandboxPolicy::INITIALIZATION_LOAD_BLOCKS);
|
||||
ScheduleBatchPriority();
|
||||
@@ -934,7 +933,7 @@ void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFile
|
||||
}
|
||||
}
|
||||
|
||||
if (args.GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) {
|
||||
if (chainman.m_blockman.StopAfterBlockImport()) {
|
||||
LogPrintf("Stopping after block import\n");
|
||||
StartShutdown();
|
||||
return;
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
class ArgsManager;
|
||||
class BlockValidationState;
|
||||
class CBlock;
|
||||
class CBlockFileInfo;
|
||||
@@ -36,7 +35,6 @@ struct Params;
|
||||
}
|
||||
|
||||
namespace node {
|
||||
static constexpr bool DEFAULT_STOPAFTERBLOCKIMPORT{false};
|
||||
|
||||
/** The pre-allocation chunk size for blk?????.dat files (since 0.8) */
|
||||
static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB
|
||||
@@ -210,6 +208,8 @@ public:
|
||||
|
||||
[[nodiscard]] bool LoadingBlocks() const { return m_importing || fReindex; }
|
||||
|
||||
[[nodiscard]] bool StopAfterBlockImport() const { return m_opts.stop_after_block_import; }
|
||||
|
||||
/** Calculate the amount of disk space the block & undo files currently use */
|
||||
uint64_t CalculateCurrentUsage();
|
||||
|
||||
@@ -249,7 +249,7 @@ public:
|
||||
void CleanupBlockRevFiles() const;
|
||||
};
|
||||
|
||||
void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFiles, const ArgsManager& args, const fs::path& mempool_path);
|
||||
void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFiles, const fs::path& mempool_path);
|
||||
} // namespace node
|
||||
|
||||
#endif // BITCOIN_NODE_BLOCKSTORAGE_H
|
||||
|
||||
Reference in New Issue
Block a user