diff options
Diffstat (limited to 'src/chainparams.cpp')
-rw-r--r-- | src/chainparams.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/chainparams.cpp b/src/chainparams.cpp index d3d358a3f0..6f4453d1fe 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -5,6 +5,7 @@ #include <chainparams.h> +#include <chainparamsbase.h> #include <chainparamsseeds.h> #include <common/args.h> #include <consensus/merkle.h> @@ -12,6 +13,7 @@ #include <hash.h> // for signet block challenge hash #include <logging.h> #include <script/interpreter.h> +#include <util/chaintype.h> #include <util/string.h> #include <assert.h> @@ -97,26 +99,29 @@ const CChainParams &Params() { return *globalChainParams; } -std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const std::string& chain) +std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const ChainType chain) { - if (chain == CBaseChainParams::MAIN) { + switch (chain) { + case ChainType::MAIN: return CChainParams::Main(); - } else if (chain == CBaseChainParams::TESTNET) { + case ChainType::TESTNET: return CChainParams::TestNet(); - } else if (chain == CBaseChainParams::SIGNET) { + case ChainType::SIGNET: { auto opts = CChainParams::SigNetOptions{}; ReadSigNetArgs(args, opts); return CChainParams::SigNet(opts); - } else if (chain == CBaseChainParams::REGTEST) { + } + case ChainType::REGTEST: { auto opts = CChainParams::RegTestOptions{}; ReadRegTestArgs(args, opts); return CChainParams::RegTest(opts); } - throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain)); + } + assert(false); } -void SelectParams(const std::string& network) +void SelectParams(const ChainType chain) { - SelectBaseParams(network); - globalChainParams = CreateChainParams(gArgs, network); + SelectBaseParams(chain); + globalChainParams = CreateChainParams(gArgs, chain); } |