diff options
author | Jorge Timón <jtimon@jtimon.cc> | 2015-06-30 21:39:49 +0200 |
---|---|---|
committer | Jorge Timón <jtimon@jtimon.cc> | 2015-10-20 14:22:44 +0200 |
commit | f3525e24e3a156eaa004ca28a59fe2d449dc1f9e (patch) | |
tree | 6fceee33ff5c9efff9e97ea0045f4726239714b0 /src/chainparams.cpp | |
parent | 49793fbb097e9f00149a054adeddad07f0444c12 (diff) |
Chainparams: Replace CBaseChainParams::Network enum with string constants (suggested by Wladimir)
Diffstat (limited to 'src/chainparams.cpp')
-rw-r--r-- | src/chainparams.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 9c843f6e7e..02c417c38d 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -5,6 +5,7 @@ #include "chainparams.h" +#include "tinyformat.h" #include "util.h" #include "utilstrencodings.h" @@ -260,28 +261,27 @@ const CChainParams &Params() { return *pCurrentParams; } -CChainParams &Params(CBaseChainParams::Network network) { - switch (network) { - case CBaseChainParams::MAIN: +CChainParams& Params(const std::string& chain) +{ + if (chain == CBaseChainParams::MAIN) return mainParams; - case CBaseChainParams::TESTNET: + else if (chain == CBaseChainParams::TESTNET) return testNetParams; - case CBaseChainParams::REGTEST: + else if (chain == CBaseChainParams::REGTEST) return regTestParams; - default: - assert(false && "Unimplemented network"); - return mainParams; - } + else + throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain)); } -void SelectParams(CBaseChainParams::Network network) { +void SelectParams(const std::string& network) +{ SelectBaseParams(network); pCurrentParams = &Params(network); } bool SelectParamsFromCommandLine() { - CBaseChainParams::Network network = NetworkIdFromCommandLine(); + std::string network = ChainNameFromCommandLine(); if (network == CBaseChainParams::MAX_NETWORK_TYPES) return false; |