refactor: Reduce number of LoadChainstate parameters

This commit is contained in:
Russell Yanofsky
2021-12-01 18:16:29 -05:00
parent 5560682a44
commit 3b91d4b994
5 changed files with 86 additions and 113 deletions

View File

@@ -54,8 +54,6 @@
using node::BlockAssembler;
using node::CalculateCacheSizes;
using node::fPruneMode;
using node::fReindex;
using node::LoadChainstate;
using node::NodeContext;
using node::RegenerateCommitments;
@@ -218,24 +216,19 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
// instead of unit tests, but for now we need these here.
RegisterAllCoreRPCCommands(tableRPC);
auto maybe_load_error = LoadChainstate(fReindex.load(),
*Assert(m_node.chainman.get()),
Assert(m_node.mempool.get()),
fPruneMode,
m_args.GetBoolArg("-reindex-chainstate", false),
m_cache_sizes.block_tree_db,
m_cache_sizes.coins_db,
m_cache_sizes.coins,
/*block_tree_db_in_memory=*/true,
/*coins_db_in_memory=*/true);
node::ChainstateLoadOptions options;
options.mempool = Assert(m_node.mempool.get());
options.block_tree_db_in_memory = true;
options.coins_db_in_memory = true;
options.reindex = node::fReindex;
options.reindex_chainstate = m_args.GetBoolArg("-reindex-chainstate", false);
options.prune = node::fPruneMode;
options.check_blocks = m_args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS);
options.check_level = m_args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL);
auto maybe_load_error = LoadChainstate(*Assert(m_node.chainman), m_cache_sizes, options);
assert(!maybe_load_error.has_value());
auto maybe_verify_error = VerifyLoadedChainstate(
*Assert(m_node.chainman),
fReindex.load(),
m_args.GetBoolArg("-reindex-chainstate", false),
m_args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS),
m_args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL));
auto maybe_verify_error = VerifyLoadedChainstate(*Assert(m_node.chainman), options);
assert(!maybe_verify_error.has_value());
BlockValidationState state;