Merge #9911: Wshadow: various gcc fixes
[bitcoinplatinum.git] / src / chainparamsbase.cpp
blobcb71a8b550c7582fd87052d2c1e0576f36f9d3d1
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2015 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 #include "chainparamsbase.h"
8 #include "tinyformat.h"
9 #include "util.h"
11 #include <assert.h>
13 const std::string CBaseChainParams::MAIN = "main";
14 const std::string CBaseChainParams::TESTNET = "test";
15 const std::string CBaseChainParams::REGTEST = "regtest";
17 void AppendParamsHelpMessages(std::string& strUsage, bool debugHelp)
19 strUsage += HelpMessageGroup(_("Chain selection options:"));
20 strUsage += HelpMessageOpt("-testnet", _("Use the test chain"));
21 if (debugHelp) {
22 strUsage += HelpMessageOpt("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
23 "This is intended for regression testing tools and app development.");
27 /**
28 * Main network
30 class CBaseMainParams : public CBaseChainParams
32 public:
33 CBaseMainParams()
35 nRPCPort = 8332;
38 static CBaseMainParams mainParams;
40 /**
41 * Testnet (v3)
43 class CBaseTestNetParams : public CBaseChainParams
45 public:
46 CBaseTestNetParams()
48 nRPCPort = 18332;
49 strDataDir = "testnet3";
52 static CBaseTestNetParams testNetParams;
55 * Regression test
57 class CBaseRegTestParams : public CBaseChainParams
59 public:
60 CBaseRegTestParams()
62 nRPCPort = 18332;
63 strDataDir = "regtest";
66 static CBaseRegTestParams regTestParams;
68 static CBaseChainParams* pCurrentBaseParams = 0;
70 const CBaseChainParams& BaseParams()
72 assert(pCurrentBaseParams);
73 return *pCurrentBaseParams;
76 CBaseChainParams& BaseParams(const std::string& chain)
78 if (chain == CBaseChainParams::MAIN)
79 return mainParams;
80 else if (chain == CBaseChainParams::TESTNET)
81 return testNetParams;
82 else if (chain == CBaseChainParams::REGTEST)
83 return regTestParams;
84 else
85 throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
88 void SelectBaseParams(const std::string& chain)
90 pCurrentBaseParams = &BaseParams(chain);
93 std::string ChainNameFromCommandLine()
95 bool fRegTest = GetBoolArg("-regtest", false);
96 bool fTestNet = GetBoolArg("-testnet", false);
98 if (fTestNet && fRegTest)
99 throw std::runtime_error("Invalid combination of -regtest and -testnet.");
100 if (fRegTest)
101 return CBaseChainParams::REGTEST;
102 if (fTestNet)
103 return CBaseChainParams::TESTNET;
104 return CBaseChainParams::MAIN;
107 bool AreBaseParamsConfigured()
109 return pCurrentBaseParams != NULL;