|
|
@ -5,10 +5,16 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "chainparamsbase.h" |
|
|
|
#include "chainparamsbase.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "tinyformat.h" |
|
|
|
#include "util.h" |
|
|
|
#include "util.h" |
|
|
|
|
|
|
|
|
|
|
|
#include <assert.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 |
|
|
|
* Main network |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -71,25 +77,19 @@ const CBaseChainParams& BaseParams() |
|
|
|
return *pCurrentBaseParams; |
|
|
|
return *pCurrentBaseParams; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SelectBaseParams(CBaseChainParams::Network network) |
|
|
|
void SelectBaseParams(const std::string& chain) |
|
|
|
{ |
|
|
|
{ |
|
|
|
switch (network) { |
|
|
|
if (chain == CBaseChainParams::MAIN) |
|
|
|
case CBaseChainParams::MAIN: |
|
|
|
|
|
|
|
pCurrentBaseParams = &mainParams; |
|
|
|
pCurrentBaseParams = &mainParams; |
|
|
|
break; |
|
|
|
else if (chain == CBaseChainParams::TESTNET) |
|
|
|
case CBaseChainParams::TESTNET: |
|
|
|
|
|
|
|
pCurrentBaseParams = &testNetParams; |
|
|
|
pCurrentBaseParams = &testNetParams; |
|
|
|
break; |
|
|
|
else if (chain == CBaseChainParams::REGTEST) |
|
|
|
case CBaseChainParams::REGTEST: |
|
|
|
|
|
|
|
pCurrentBaseParams = ®TestParams; |
|
|
|
pCurrentBaseParams = ®TestParams; |
|
|
|
break; |
|
|
|
else |
|
|
|
default: |
|
|
|
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain)); |
|
|
|
assert(false && "Unimplemented network"); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CBaseChainParams::Network NetworkIdFromCommandLine() |
|
|
|
std::string ChainNameFromCommandLine() |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool fRegTest = GetBoolArg("-regtest", false); |
|
|
|
bool fRegTest = GetBoolArg("-regtest", false); |
|
|
|
bool fTestNet = GetBoolArg("-testnet", false); |
|
|
|
bool fTestNet = GetBoolArg("-testnet", false); |
|
|
@ -105,7 +105,7 @@ CBaseChainParams::Network NetworkIdFromCommandLine() |
|
|
|
|
|
|
|
|
|
|
|
bool SelectBaseParamsFromCommandLine() |
|
|
|
bool SelectBaseParamsFromCommandLine() |
|
|
|
{ |
|
|
|
{ |
|
|
|
CBaseChainParams::Network network = NetworkIdFromCommandLine(); |
|
|
|
std::string network = ChainNameFromCommandLine(); |
|
|
|
if (network == CBaseChainParams::MAX_NETWORK_TYPES) |
|
|
|
if (network == CBaseChainParams::MAX_NETWORK_TYPES) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|