diff options
Diffstat (limited to 'src/chainparamsbase.cpp')
-rw-r--r-- | src/chainparamsbase.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp index 9c87bf2154..e46212279f 100644 --- a/src/chainparamsbase.cpp +++ b/src/chainparamsbase.cpp @@ -5,10 +5,16 @@ #include "chainparamsbase.h" +#include "tinyformat.h" #include "util.h" #include <assert.h> +const std::string CBaseChainParams::MAIN = "main"; +const std::string CBaseChainParams::TESTNET = "test"; +const std::string CBaseChainParams::REGTEST = "regtest"; +const std::string CBaseChainParams::MAX_NETWORK_TYPES = "unknown_chain"; + /** * Main network */ @@ -71,25 +77,19 @@ const CBaseChainParams& BaseParams() return *pCurrentBaseParams; } -void SelectBaseParams(CBaseChainParams::Network network) +void SelectBaseParams(const std::string& chain) { - switch (network) { - case CBaseChainParams::MAIN: + if (chain == CBaseChainParams::MAIN) pCurrentBaseParams = &mainParams; - break; - case CBaseChainParams::TESTNET: + else if (chain == CBaseChainParams::TESTNET) pCurrentBaseParams = &testNetParams; - break; - case CBaseChainParams::REGTEST: + else if (chain == CBaseChainParams::REGTEST) pCurrentBaseParams = ®TestParams; - break; - default: - assert(false && "Unimplemented network"); - return; - } + else + throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain)); } -CBaseChainParams::Network NetworkIdFromCommandLine() +std::string ChainNameFromCommandLine() { bool fRegTest = GetBoolArg("-regtest", false); bool fTestNet = GetBoolArg("-testnet", false); @@ -105,7 +105,7 @@ CBaseChainParams::Network NetworkIdFromCommandLine() bool SelectBaseParamsFromCommandLine() { - CBaseChainParams::Network network = NetworkIdFromCommandLine(); + std::string network = ChainNameFromCommandLine(); if (network == CBaseChainParams::MAX_NETWORK_TYPES) return false; |