Changeset View
Changeset View
Standalone View
Standalone View
src/chainparamsbase.cpp
Show All 18 Lines | gArgs.AddArg("-regtest", | ||||
"Enter regression test mode, which uses a special chain in " | "Enter regression test mode, which uses a special chain in " | ||||
"which blocks can be solved instantly. This is intended for " | "which blocks can be solved instantly. This is intended for " | ||||
"regression testing tools and app development.", | "regression testing tools and app development.", | ||||
true, OptionsCategory::CHAINPARAMS); | true, OptionsCategory::CHAINPARAMS); | ||||
gArgs.AddArg("-testnet", _("Use the test chain"), false, | gArgs.AddArg("-testnet", _("Use the test chain"), false, | ||||
OptionsCategory::CHAINPARAMS); | OptionsCategory::CHAINPARAMS); | ||||
} | } | ||||
/** | |||||
* Main network | |||||
*/ | |||||
class CBaseMainParams : public CBaseChainParams { | |||||
public: | |||||
CBaseMainParams() { nRPCPort = 8332; } | |||||
}; | |||||
/** | |||||
* Testnet (v3) | |||||
*/ | |||||
class CBaseTestNetParams : public CBaseChainParams { | |||||
public: | |||||
CBaseTestNetParams() { | |||||
nRPCPort = 18332; | |||||
strDataDir = "testnet3"; | |||||
} | |||||
}; | |||||
/* | |||||
* Regression test | |||||
*/ | |||||
class CBaseRegTestParams : public CBaseChainParams { | |||||
public: | |||||
CBaseRegTestParams() { | |||||
nRPCPort = 18443; | |||||
strDataDir = "regtest"; | |||||
} | |||||
}; | |||||
static std::unique_ptr<CBaseChainParams> globalChainBaseParams; | static std::unique_ptr<CBaseChainParams> globalChainBaseParams; | ||||
const CBaseChainParams &BaseParams() { | const CBaseChainParams &BaseParams() { | ||||
assert(globalChainBaseParams); | assert(globalChainBaseParams); | ||||
return *globalChainBaseParams; | return *globalChainBaseParams; | ||||
} | } | ||||
std::unique_ptr<CBaseChainParams> | std::unique_ptr<CBaseChainParams> | ||||
CreateBaseChainParams(const std::string &chain) { | CreateBaseChainParams(const std::string &chain) { | ||||
if (chain == CBaseChainParams::MAIN) | if (chain == CBaseChainParams::MAIN) | ||||
return std::unique_ptr<CBaseChainParams>(new CBaseMainParams()); | return std::make_unique<CBaseChainParams>("", 8332); | ||||
else if (chain == CBaseChainParams::TESTNET) | else if (chain == CBaseChainParams::TESTNET) | ||||
return std::unique_ptr<CBaseChainParams>(new CBaseTestNetParams()); | return std::make_unique<CBaseChainParams>("testnet3", 18332); | ||||
else if (chain == CBaseChainParams::REGTEST) | else if (chain == CBaseChainParams::REGTEST) | ||||
return std::unique_ptr<CBaseChainParams>(new CBaseRegTestParams()); | return std::make_unique<CBaseChainParams>("regtest", 18443); | ||||
else | else | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
strprintf("%s: Unknown chain %s.", __func__, chain)); | strprintf("%s: Unknown chain %s.", __func__, chain)); | ||||
} | } | ||||
void SelectBaseParams(const std::string &chain) { | void SelectBaseParams(const std::string &chain) { | ||||
globalChainBaseParams = CreateBaseChainParams(chain); | globalChainBaseParams = CreateBaseChainParams(chain); | ||||
gArgs.SelectConfigNetwork(chain); | gArgs.SelectConfigNetwork(chain); | ||||
} | } |