mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-02-02 18:24:25 +00:00
Merge pull request #4804 from jtimon/chainparams3
Remove CBaseChainParams::NetworkID()
This commit is contained in:
commit
494ff05a4c
@ -354,10 +354,13 @@ void SelectParams(CBaseChainParams::Network network) {
|
|||||||
pCurrentParams = &Params(network);
|
pCurrentParams = &Params(network);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SelectParamsFromCommandLine() {
|
bool SelectParamsFromCommandLine()
|
||||||
if (!SelectBaseParamsFromCommandLine())
|
{
|
||||||
|
CBaseChainParams::Network network = NetworkIdFromCommandLine();
|
||||||
|
if (network == CBaseChainParams::MAX_NETWORK_TYPES)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
SelectParams(BaseParams().NetworkID());
|
SelectBaseParams(network);
|
||||||
|
SelectParams(network);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -100,22 +100,27 @@ void SelectBaseParams(CBaseChainParams::Network network)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SelectBaseParamsFromCommandLine()
|
CBaseChainParams::Network 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 CBaseChainParams::MAX_NETWORK_TYPES;
|
||||||
}
|
if (fRegTest)
|
||||||
|
return CBaseChainParams::REGTEST;
|
||||||
|
if (fTestNet)
|
||||||
|
return CBaseChainParams::TESTNET;
|
||||||
|
return CBaseChainParams::MAIN;
|
||||||
|
}
|
||||||
|
|
||||||
if (fRegTest) {
|
bool SelectBaseParamsFromCommandLine()
|
||||||
SelectBaseParams(CBaseChainParams::REGTEST);
|
{
|
||||||
} else if (fTestNet) {
|
CBaseChainParams::Network network = NetworkIdFromCommandLine();
|
||||||
SelectBaseParams(CBaseChainParams::TESTNET);
|
if (network == CBaseChainParams::MAX_NETWORK_TYPES)
|
||||||
} else {
|
return false;
|
||||||
SelectBaseParams(CBaseChainParams::MAIN);
|
|
||||||
}
|
SelectBaseParams(network);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ 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; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CBaseChainParams() {}
|
CBaseChainParams() {}
|
||||||
@ -46,7 +45,13 @@ const CBaseChainParams& BaseParams();
|
|||||||
void SelectBaseParams(CBaseChainParams::Network network);
|
void SelectBaseParams(CBaseChainParams::Network network);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Looks for -regtest or -testnet and then calls SelectParams as appropriate.
|
* Looks for -regtest or -testnet and returns the appropriate Network ID.
|
||||||
|
* Returns MAX_NETWORK_TYPES if an invalid combination is given.
|
||||||
|
*/
|
||||||
|
CBaseChainParams::Network NetworkIdFromCommandLine();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls 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();
|
||||||
|
12
src/util.cpp
12
src/util.cpp
@ -395,7 +395,8 @@ boost::filesystem::path GetDefaultDataDir()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static boost::filesystem::path pathCached[CBaseChainParams::MAX_NETWORK_TYPES+1];
|
static boost::filesystem::path pathCached;
|
||||||
|
static boost::filesystem::path pathCachedNetSpecific;
|
||||||
static CCriticalSection csPathCached;
|
static CCriticalSection csPathCached;
|
||||||
|
|
||||||
const boost::filesystem::path &GetDataDir(bool fNetSpecific)
|
const boost::filesystem::path &GetDataDir(bool fNetSpecific)
|
||||||
@ -404,10 +405,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific)
|
|||||||
|
|
||||||
LOCK(csPathCached);
|
LOCK(csPathCached);
|
||||||
|
|
||||||
int nNet = CBaseChainParams::MAX_NETWORK_TYPES;
|
fs::path &path = fNetSpecific ? pathCachedNetSpecific : pathCached;
|
||||||
if (fNetSpecific) nNet = BaseParams().NetworkID();
|
|
||||||
|
|
||||||
fs::path &path = pathCached[nNet];
|
|
||||||
|
|
||||||
// This can be called during exceptions by LogPrintf(), so we cache the
|
// This can be called during exceptions by LogPrintf(), so we cache the
|
||||||
// value so we don't have to do memory allocations after that.
|
// value so we don't have to do memory allocations after that.
|
||||||
@ -433,8 +431,8 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific)
|
|||||||
|
|
||||||
void ClearDatadirCache()
|
void ClearDatadirCache()
|
||||||
{
|
{
|
||||||
std::fill(&pathCached[0], &pathCached[CBaseChainParams::MAX_NETWORK_TYPES+1],
|
pathCached = boost::filesystem::path();
|
||||||
boost::filesystem::path());
|
pathCachedNetSpecific = boost::filesystem::path();
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::filesystem::path GetConfigFile()
|
boost::filesystem::path GetConfigFile()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user