aboutsummaryrefslogtreecommitdiff
path: root/src/chainparamsbase.cpp
diff options
context:
space:
mode:
authorJorge Timón <jtimon@jtimon.cc>2015-05-22 03:50:01 +0200
committerJorge Timón <jtimon@jtimon.cc>2017-05-03 18:15:47 +0200
commitf87f3626e35e7edae37e14f5156809325ad18cb2 (patch)
tree218b637261c6b1a2293539685ca6df1c5e99e933 /src/chainparamsbase.cpp
parent35da2aeed7d4000dde93957c3b6e048ab83c4f2b (diff)
Chainparams: Use a regular factory for creating chainparams
Diffstat (limited to 'src/chainparamsbase.cpp')
-rw-r--r--src/chainparamsbase.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp
index d013cc1450..43c9a13c54 100644
--- a/src/chainparamsbase.cpp
+++ b/src/chainparamsbase.cpp
@@ -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()