From ba8fc7d788932b25864fb260ca14983aa2398c23 Mon Sep 17 00:00:00 2001 From: TheCharlatan Date: Mon, 17 Apr 2023 22:20:59 +0200 Subject: refactor: Replace string chain name constants with ChainTypes This commit effectively moves the definition of these constants out of the chainparamsbase to their own file. Using the ChainType enums provides better type safety compared to passing around strings. The commit is part of an ongoing effort to decouple the libbitcoinkernel library from the ArgsManager and other functionality that should not be part of the kernel library. --- src/chainparamsbase.h | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/chainparamsbase.h') diff --git a/src/chainparamsbase.h b/src/chainparamsbase.h index d593cff722..73e449d11b 100644 --- a/src/chainparamsbase.h +++ b/src/chainparamsbase.h @@ -5,6 +5,8 @@ #ifndef BITCOIN_CHAINPARAMSBASE_H #define BITCOIN_CHAINPARAMSBASE_H +#include + #include #include @@ -17,14 +19,6 @@ class ArgsManager; class CBaseChainParams { public: - ///@{ - /** Chain name strings */ - static const std::string MAIN; - static const std::string TESTNET; - static const std::string SIGNET; - static const std::string REGTEST; - ///@} - const std::string& DataDir() const { return strDataDir; } uint16_t RPCPort() const { return m_rpc_port; } uint16_t OnionServiceTargetPort() const { return m_onion_service_target_port; } @@ -44,7 +38,7 @@ private: * @returns a CBaseChainParams* of the chosen chain. * @throws a std::runtime_error if the chain is not supported. */ -std::unique_ptr CreateBaseChainParams(const std::string& chain); +std::unique_ptr CreateBaseChainParams(const ChainType chain); /** *Set the arguments for chainparams @@ -57,7 +51,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman); */ const CBaseChainParams& BaseParams(); -/** Sets the params returned by Params() to those for the given network. */ -void SelectBaseParams(const std::string& chain); +/** Sets the params returned by Params() to those for the given chain. */ +void SelectBaseParams(const ChainType chain); #endif // BITCOIN_CHAINPARAMSBASE_H -- cgit v1.2.3