Refactor: One CBaseChainParams should be enough
This commit is contained in:
parent
d405beea26
commit
1687cb4a87
2 changed files with 6 additions and 43 deletions
|
@ -24,44 +24,6 @@ void AppendParamsHelpMessages(std::string& strUsage, bool debugHelp)
|
|||
strUsage += HelpMessageOpt("-testnet", _("Use the test chain"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
const CBaseChainParams& BaseParams()
|
||||
|
@ -73,11 +35,11 @@ const CBaseChainParams& BaseParams()
|
|||
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain)
|
||||
{
|
||||
if (chain == CBaseChainParams::MAIN)
|
||||
return std::unique_ptr<CBaseChainParams>(new CBaseMainParams());
|
||||
return MakeUnique<CBaseChainParams>("", 8332);
|
||||
else if (chain == CBaseChainParams::TESTNET)
|
||||
return std::unique_ptr<CBaseChainParams>(new CBaseTestNetParams());
|
||||
return MakeUnique<CBaseChainParams>("testnet3", 18332);
|
||||
else if (chain == CBaseChainParams::REGTEST)
|
||||
return std::unique_ptr<CBaseChainParams>(new CBaseRegTestParams());
|
||||
return MakeUnique<CBaseChainParams>("regtest", 18443);
|
||||
else
|
||||
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
|
||||
}
|
||||
|
|
|
@ -24,9 +24,10 @@ public:
|
|||
const std::string& DataDir() const { return strDataDir; }
|
||||
int RPCPort() const { return nRPCPort; }
|
||||
|
||||
protected:
|
||||
CBaseChainParams() {}
|
||||
CBaseChainParams() = delete;
|
||||
CBaseChainParams(const std::string& data_dir, int rpc_port) : nRPCPort(rpc_port), strDataDir(data_dir) {}
|
||||
|
||||
private:
|
||||
int nRPCPort;
|
||||
std::string strDataDir;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue