diff options
author | Russell Yanofsky <russ@yanofsky.org> | 2021-12-01 18:16:29 -0500 |
---|---|---|
committer | Russell Yanofsky <russ@yanofsky.org> | 2022-07-19 15:54:52 -0500 |
commit | 3b91d4b9947adbec74721f538e46c712db22587c (patch) | |
tree | f5fb6c690a92727ff492a1ae2dce4058052ac885 /src/node/chainstate.h | |
parent | 5560682a4464852eb3c244c1ddf9eea02dc962b2 (diff) | |
download | bitcoin-3b91d4b9947adbec74721f538e46c712db22587c.tar.xz |
refactor: Reduce number of LoadChainstate parameters
Diffstat (limited to 'src/node/chainstate.h')
-rw-r--r-- | src/node/chainstate.h | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/node/chainstate.h b/src/node/chainstate.h index 5c495da229..4851ef1ae6 100644 --- a/src/node/chainstate.h +++ b/src/node/chainstate.h @@ -5,6 +5,8 @@ #ifndef BITCOIN_NODE_CHAINSTATE_H #define BITCOIN_NODE_CHAINSTATE_H +#include <validation.h> + #include <cstdint> #include <functional> #include <optional> @@ -13,6 +15,22 @@ class ChainstateManager; class CTxMemPool; namespace node { + +struct CacheSizes; + +struct ChainstateLoadOptions { + CTxMemPool* mempool{nullptr}; + bool block_tree_db_in_memory{false}; + bool coins_db_in_memory{false}; + bool reindex{false}; + bool reindex_chainstate{false}; + bool prune{false}; + int64_t check_blocks{DEFAULT_CHECKBLOCKS}; + int64_t check_level{DEFAULT_CHECKLEVEL}; + std::function<bool()> check_interrupt; + std::function<void()> coins_error_cb; +}; + enum class ChainstateLoadingError { ERROR_LOADING_BLOCK_DB, ERROR_BAD_GENESIS_BLOCK, @@ -52,18 +70,8 @@ enum class ChainstateLoadingError { * - else * - Success! */ -std::optional<ChainstateLoadingError> LoadChainstate(bool fReset, - ChainstateManager& chainman, - CTxMemPool* mempool, - bool fPruneMode, - bool fReindexChainState, - int64_t nBlockTreeDBCache, - int64_t nCoinDBCache, - int64_t nCoinCacheUsage, - bool block_tree_db_in_memory, - bool coins_db_in_memory, - std::function<bool()> shutdown_requested = nullptr, - std::function<void()> coins_error_cb = nullptr); +std::optional<ChainstateLoadingError> LoadChainstate(ChainstateManager& chainman, const CacheSizes& cache_sizes, + const ChainstateLoadOptions& options); enum class ChainstateLoadVerifyError { ERROR_BLOCK_FROM_FUTURE, @@ -72,10 +80,7 @@ enum class ChainstateLoadVerifyError { }; std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManager& chainman, - bool fReset, - bool fReindexChainState, - int check_blocks, - int check_level); + const ChainstateLoadOptions& options); } // namespace node #endif // BITCOIN_NODE_CHAINSTATE_H |