Remove CBaseChainParams::NetworkID()

This commit is contained in:
jtimon 2014-09-01 00:41:28 +02:00
parent f297479a19
commit 3fdb9e8c15
3 changed files with 28 additions and 16 deletions

View file

@ -240,10 +240,13 @@ void SelectParams(CBaseChainParams::Network network) {
pCurrentParams = &Params(network); pCurrentParams = &Params(network);
} }
bool SelectParamsFromCommandLine() { bool SelectParamsFromCommandLine()
if (!SelectBaseParamsFromCommandLine()) {
CBaseChainParams::Network network = CBaseChainParams::NetworkIdFromCommandLine();
if (network == CBaseChainParams::MAX_NETWORK_TYPES)
return false; return false;
SelectParams(BaseParams().NetworkID()); SelectBaseParams(network);
SelectParams(network);
return true; return true;
} }

View file

@ -83,22 +83,27 @@ void SelectBaseParams(CBaseChainParams::Network network)
} }
} }
bool SelectBaseParamsFromCommandLine() CBaseChainParams::Network CBaseChainParams::NetworkIdFromCommandLine()
{ {
bool fRegTest = GetBoolArg("-regtest", false); bool fRegTest = GetBoolArg("-regtest", false);
bool fTestNet = GetBoolArg("-testnet", false); bool fTestNet = GetBoolArg("-testnet", false);
if (fTestNet && fRegTest) { if (fTestNet && fRegTest)
return false; return MAX_NETWORK_TYPES;
} if (fRegTest)
return REGTEST;
if (fTestNet)
return TESTNET;
return MAIN;
}
if (fRegTest) { bool SelectBaseParamsFromCommandLine()
SelectBaseParams(CBaseChainParams::REGTEST); {
} else if (fTestNet) { CBaseChainParams::Network network = CBaseChainParams::NetworkIdFromCommandLine();
SelectBaseParams(CBaseChainParams::TESTNET); if (network == CBaseChainParams::MAX_NETWORK_TYPES)
} else { return false;
SelectBaseParams(CBaseChainParams::MAIN);
} SelectBaseParams(network);
return true; return true;
} }

View file

@ -25,8 +25,12 @@ public:
const std::string& DataDir() const { return strDataDir; } const std::string& DataDir() const { return strDataDir; }
int RPCPort() const { return nRPCPort; } 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: protected:
CBaseChainParams() {} CBaseChainParams() {}
@ -45,7 +49,7 @@ const CBaseChainParams& BaseParams();
void SelectBaseParams(CBaseChainParams::Network network); 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. * Returns false if an invalid combination is given.
*/ */
bool SelectBaseParamsFromCommandLine(); bool SelectBaseParamsFromCommandLine();