]>
Commit | Line | Data |
---|---|---|
84ce18ca WL |
1 | // Copyright (c) 2010 Satoshi Nakamoto |
2 | // Copyright (c) 2009-2014 The Bitcoin developers | |
3 | // Distributed under the MIT/X11 software license, see the accompanying | |
4 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | |
5 | ||
6 | #include "chainparamsbase.h" | |
7 | ||
84ce18ca WL |
8 | #include "util.h" |
9 | ||
187115c0 PK |
10 | #include <assert.h> |
11 | ||
84ce18ca WL |
12 | #include <boost/assign/list_of.hpp> |
13 | ||
14 | using namespace boost::assign; | |
15 | ||
16 | // | |
17 | // Main network | |
18 | // | |
19 | ||
20 | class CBaseMainParams : public CBaseChainParams { | |
21 | public: | |
22 | CBaseMainParams() { | |
23 | networkID = CBaseChainParams::MAIN; | |
24 | nRPCPort = 8332; | |
25 | } | |
26 | }; | |
27 | static CBaseMainParams mainParams; | |
28 | ||
29 | // | |
30 | // Testnet (v3) | |
31 | // | |
32 | class CBaseTestNetParams : public CBaseMainParams { | |
33 | public: | |
34 | CBaseTestNetParams() { | |
35 | networkID = CBaseChainParams::TESTNET; | |
36 | nRPCPort = 18332; | |
37 | strDataDir = "testnet3"; | |
38 | } | |
39 | }; | |
40 | static CBaseTestNetParams testNetParams; | |
41 | ||
42 | // | |
43 | // Regression test | |
44 | // | |
45 | class CBaseRegTestParams : public CBaseTestNetParams { | |
46 | public: | |
47 | CBaseRegTestParams() { | |
48 | networkID = CBaseChainParams::REGTEST; | |
49 | strDataDir = "regtest"; | |
50 | } | |
51 | }; | |
52 | static CBaseRegTestParams regTestParams; | |
53 | ||
54 | static CBaseChainParams *pCurrentBaseParams = 0; | |
55 | ||
56 | const CBaseChainParams &BaseParams() { | |
57 | assert(pCurrentBaseParams); | |
58 | return *pCurrentBaseParams; | |
59 | } | |
60 | ||
61 | void SelectBaseParams(CBaseChainParams::Network network) { | |
62 | switch (network) { | |
63 | case CBaseChainParams::MAIN: | |
64 | pCurrentBaseParams = &mainParams; | |
65 | break; | |
66 | case CBaseChainParams::TESTNET: | |
67 | pCurrentBaseParams = &testNetParams; | |
68 | break; | |
69 | case CBaseChainParams::REGTEST: | |
70 | pCurrentBaseParams = ®TestParams; | |
71 | break; | |
72 | default: | |
73 | assert(false && "Unimplemented network"); | |
74 | return; | |
75 | } | |
76 | } | |
77 | ||
78 | bool SelectBaseParamsFromCommandLine() { | |
79 | bool fRegTest = GetBoolArg("-regtest", false); | |
80 | bool fTestNet = GetBoolArg("-testnet", false); | |
81 | ||
82 | if (fTestNet && fRegTest) { | |
83 | return false; | |
84 | } | |
85 | ||
86 | if (fRegTest) { | |
87 | SelectBaseParams(CBaseChainParams::REGTEST); | |
88 | } else if (fTestNet) { | |
89 | SelectBaseParams(CBaseChainParams::TESTNET); | |
90 | } else { | |
91 | SelectBaseParams(CBaseChainParams::MAIN); | |
92 | } | |
93 | return true; | |
94 | } | |
96ff9d64 WL |
95 | |
96 | bool AreBaseParamsConfigured() { | |
97 | return pCurrentBaseParams != NULL; | |
98 | } |