mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-11 17:52:48 +01:00
Chainparams: Use a regular factory for creating chainparams
This commit is contained in:
@@ -35,7 +35,6 @@ public:
|
||||
nRPCPort = 8332;
|
||||
}
|
||||
};
|
||||
static CBaseMainParams mainParams;
|
||||
|
||||
/**
|
||||
* Testnet (v3)
|
||||
@@ -49,7 +48,6 @@ public:
|
||||
strDataDir = "testnet3";
|
||||
}
|
||||
};
|
||||
static CBaseTestNetParams testNetParams;
|
||||
|
||||
/*
|
||||
* Regression test
|
||||
@@ -63,31 +61,30 @@ public:
|
||||
strDataDir = "regtest";
|
||||
}
|
||||
};
|
||||
static CBaseRegTestParams regTestParams;
|
||||
|
||||
static CBaseChainParams* pCurrentBaseParams = 0;
|
||||
static std::unique_ptr<CBaseChainParams> globalChainBaseParams;
|
||||
|
||||
const CBaseChainParams& BaseParams()
|
||||
{
|
||||
assert(pCurrentBaseParams);
|
||||
return *pCurrentBaseParams;
|
||||
assert(globalChainBaseParams);
|
||||
return *globalChainBaseParams;
|
||||
}
|
||||
|
||||
CBaseChainParams& BaseParams(const std::string& chain)
|
||||
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain)
|
||||
{
|
||||
if (chain == CBaseChainParams::MAIN)
|
||||
return mainParams;
|
||||
return std::unique_ptr<CBaseChainParams>(new CBaseMainParams());
|
||||
else if (chain == CBaseChainParams::TESTNET)
|
||||
return testNetParams;
|
||||
return std::unique_ptr<CBaseChainParams>(new CBaseTestNetParams());
|
||||
else if (chain == CBaseChainParams::REGTEST)
|
||||
return regTestParams;
|
||||
return std::unique_ptr<CBaseChainParams>(new CBaseRegTestParams());
|
||||
else
|
||||
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
|
||||
}
|
||||
|
||||
void SelectBaseParams(const std::string& chain)
|
||||
{
|
||||
pCurrentBaseParams = &BaseParams(chain);
|
||||
globalChainBaseParams = CreateBaseChainParams(chain);
|
||||
}
|
||||
|
||||
std::string ChainNameFromCommandLine()
|
||||
|
||||
Reference in New Issue
Block a user