diff options
author | jtimon <jtimon@blockstream.io> | 2014-09-01 00:41:28 +0200 |
---|---|---|
committer | jtimon <jtimon@blockstream.io> | 2014-09-21 21:25:15 +0200 |
commit | 3fdb9e8c159a2bc3ac853b469dae9ba0ecf739f3 (patch) | |
tree | d4780d7151553c06d7fc4666465dcc5c02dbf409 | |
parent | f297479a1995bd147c21c58fca103cd3ab3e54c1 (diff) |
Remove CBaseChainParams::NetworkID()
-rw-r--r-- | src/chainparams.cpp | 9 | ||||
-rw-r--r-- | src/chainparamsbase.cpp | 25 | ||||
-rw-r--r-- | src/chainparamsbase.h | 8 |
3 files changed, 27 insertions, 15 deletions
diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 179db5a818..f561877d9f 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -240,10 +240,13 @@ void SelectParams(CBaseChainParams::Network network) { pCurrentParams = &Params(network); } -bool SelectParamsFromCommandLine() { - if (!SelectBaseParamsFromCommandLine()) +bool SelectParamsFromCommandLine() +{ + CBaseChainParams::Network network = CBaseChainParams::NetworkIdFromCommandLine(); + if (network == CBaseChainParams::MAX_NETWORK_TYPES) return false; - SelectParams(BaseParams().NetworkID()); + SelectBaseParams(network); + SelectParams(network); return true; } diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp index 98bb5b855f..05ef5dd463 100644 --- a/src/chainparamsbase.cpp +++ b/src/chainparamsbase.cpp @@ -83,22 +83,27 @@ void SelectBaseParams(CBaseChainParams::Network network) } } -bool SelectBaseParamsFromCommandLine() +CBaseChainParams::Network CBaseChainParams::NetworkIdFromCommandLine() { bool fRegTest = GetBoolArg("-regtest", false); bool fTestNet = GetBoolArg("-testnet", false); - if (fTestNet && fRegTest) { + if (fTestNet && fRegTest) + return MAX_NETWORK_TYPES; + if (fRegTest) + return REGTEST; + if (fTestNet) + return TESTNET; + return MAIN; +} + +bool SelectBaseParamsFromCommandLine() +{ + CBaseChainParams::Network network = CBaseChainParams::NetworkIdFromCommandLine(); + if (network == CBaseChainParams::MAX_NETWORK_TYPES) return false; - } - if (fRegTest) { - SelectBaseParams(CBaseChainParams::REGTEST); - } else if (fTestNet) { - SelectBaseParams(CBaseChainParams::TESTNET); - } else { - SelectBaseParams(CBaseChainParams::MAIN); - } + SelectBaseParams(network); return true; } diff --git a/src/chainparamsbase.h b/src/chainparamsbase.h index c054f03f17..f24337cef0 100644 --- a/src/chainparamsbase.h +++ b/src/chainparamsbase.h @@ -25,8 +25,12 @@ public: const std::string& DataDir() const { return strDataDir; } int RPCPort() const { return nRPCPort; } - Network NetworkID() const { return networkID; } + /** + * Looks for -regtest or -testnet and returns the appropriate Network ID. + * Returns MAX_NETWORK_TYPES if an invalid combination is given. + */ + static Network NetworkIdFromCommandLine(); protected: CBaseChainParams() {} @@ -45,7 +49,7 @@ const CBaseChainParams& BaseParams(); void SelectBaseParams(CBaseChainParams::Network network); /** - * Looks for -regtest or -testnet and then calls SelectParams as appropriate. + * Calls CBaseChainParams::NetworkIdFromCommandLine() and then calls SelectParams as appropriate. * Returns false if an invalid combination is given. */ bool SelectBaseParamsFromCommandLine(); |