diff options
Diffstat (limited to 'src/chainparamsbase.cpp')
-rw-r--r-- | src/chainparamsbase.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp index eb7b31923d..8cbf9e85e0 100644 --- a/src/chainparamsbase.cpp +++ b/src/chainparamsbase.cpp @@ -7,14 +7,10 @@ #include <common/args.h> #include <tinyformat.h> +#include <util/chaintype.h> #include <assert.h> -const std::string CBaseChainParams::MAIN = "main"; -const std::string CBaseChainParams::TESTNET = "test"; -const std::string CBaseChainParams::SIGNET = "signet"; -const std::string CBaseChainParams::REGTEST = "regtest"; - void SetupChainParamsBaseOptions(ArgsManager& argsman) { argsman.AddArg("-chain=<chain>", "Use the chain <chain> (default: main). Allowed values: main, test, signet, regtest", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS); @@ -40,22 +36,23 @@ const CBaseChainParams& BaseParams() * Port numbers for incoming Tor connections (8334, 18334, 38334, 18445) have * been chosen arbitrarily to keep ranges of used ports tight. */ -std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain) +std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const ChainType chain) { - if (chain == CBaseChainParams::MAIN) { + switch (chain) { + case ChainType::MAIN: return std::make_unique<CBaseChainParams>("", 8332, 8334); - } else if (chain == CBaseChainParams::TESTNET) { + case ChainType::TESTNET: return std::make_unique<CBaseChainParams>("testnet3", 18332, 18334); - } else if (chain == CBaseChainParams::SIGNET) { + case ChainType::SIGNET: return std::make_unique<CBaseChainParams>("signet", 38332, 38334); - } else if (chain == CBaseChainParams::REGTEST) { + case ChainType::REGTEST: return std::make_unique<CBaseChainParams>("regtest", 18443, 18445); } - throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain)); + assert(false); } -void SelectBaseParams(const std::string& chain) +void SelectBaseParams(const ChainType chain) { globalChainBaseParams = CreateBaseChainParams(chain); - gArgs.SelectConfigNetwork(chain); + gArgs.SelectConfigNetwork(ChainTypeToString(chain)); } |