]>
Commit | Line | Data |
---|---|---|
84ce18ca | 1 | // Copyright (c) 2010 Satoshi Nakamoto |
f914f1a7 | 2 | // Copyright (c) 2009-2014 The Bitcoin Core developers |
f2e03ffa | 3 | // Distributed under the MIT software license, see the accompanying |
84ce18ca WL |
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 | ||
f2e03ffa MF |
12 | /** |
13 | * Main network | |
14 | */ | |
20e01b1a PW |
15 | class CBaseMainParams : public CBaseChainParams |
16 | { | |
84ce18ca | 17 | public: |
20e01b1a PW |
18 | CBaseMainParams() |
19 | { | |
94cc76bf | 20 | nRPCPort = 7771; |
84ce18ca WL |
21 | } |
22 | }; | |
23 | static CBaseMainParams mainParams; | |
24 | ||
f2e03ffa MF |
25 | /** |
26 | * Testnet (v3) | |
27 | */ | |
20e01b1a PW |
28 | class CBaseTestNetParams : public CBaseMainParams |
29 | { | |
84ce18ca | 30 | public: |
20e01b1a PW |
31 | CBaseTestNetParams() |
32 | { | |
94cc76bf | 33 | nRPCPort = 17771; |
84ce18ca WL |
34 | strDataDir = "testnet3"; |
35 | } | |
36 | }; | |
37 | static CBaseTestNetParams testNetParams; | |
38 | ||
f2e03ffa MF |
39 | /* |
40 | * Regression test | |
41 | */ | |
20e01b1a PW |
42 | class CBaseRegTestParams : public CBaseTestNetParams |
43 | { | |
84ce18ca | 44 | public: |
20e01b1a PW |
45 | CBaseRegTestParams() |
46 | { | |
84ce18ca WL |
47 | strDataDir = "regtest"; |
48 | } | |
49 | }; | |
50 | static CBaseRegTestParams regTestParams; | |
51 | ||
f2e03ffa MF |
52 | /* |
53 | * Unit test | |
54 | */ | |
f0fd00cb S |
55 | class CBaseUnitTestParams : public CBaseMainParams |
56 | { | |
57 | public: | |
58 | CBaseUnitTestParams() | |
59 | { | |
f0fd00cb S |
60 | strDataDir = "unittest"; |
61 | } | |
62 | }; | |
63 | static CBaseUnitTestParams unitTestParams; | |
64 | ||
20e01b1a | 65 | static CBaseChainParams* pCurrentBaseParams = 0; |
84ce18ca | 66 | |
20e01b1a PW |
67 | const CBaseChainParams& BaseParams() |
68 | { | |
93829088 | 69 | if ( pCurrentBaseParams == 0 ) |
70 | pCurrentBaseParams = &mainParams; | |
84ce18ca WL |
71 | assert(pCurrentBaseParams); |
72 | return *pCurrentBaseParams; | |
73 | } | |
74 | ||
20e01b1a PW |
75 | void SelectBaseParams(CBaseChainParams::Network network) |
76 | { | |
84ce18ca | 77 | switch (network) { |
20e01b1a PW |
78 | case CBaseChainParams::MAIN: |
79 | pCurrentBaseParams = &mainParams; | |
80 | break; | |
81 | case CBaseChainParams::TESTNET: | |
82 | pCurrentBaseParams = &testNetParams; | |
83 | break; | |
84 | case CBaseChainParams::REGTEST: | |
85 | pCurrentBaseParams = ®TestParams; | |
86 | break; | |
87 | default: | |
88 | assert(false && "Unimplemented network"); | |
89 | return; | |
84ce18ca WL |
90 | } |
91 | } | |
92 | ||
b796cb08 | 93 | CBaseChainParams::Network NetworkIdFromCommandLine() |
20e01b1a | 94 | { |
84ce18ca WL |
95 | bool fRegTest = GetBoolArg("-regtest", false); |
96 | bool fTestNet = GetBoolArg("-testnet", false); | |
97 | ||
3fdb9e8c | 98 | if (fTestNet && fRegTest) |
b796cb08 | 99 | return CBaseChainParams::MAX_NETWORK_TYPES; |
3fdb9e8c | 100 | if (fRegTest) |
b796cb08 | 101 | return CBaseChainParams::REGTEST; |
3fdb9e8c | 102 | if (fTestNet) |
b796cb08 | 103 | return CBaseChainParams::TESTNET; |
104 | return CBaseChainParams::MAIN; | |
3fdb9e8c | 105 | } |
106 | ||
ca3ce0fa | 107 | bool SelectBaseParamsFromCommandLine() |
3fdb9e8c | 108 | { |
b796cb08 | 109 | CBaseChainParams::Network network = NetworkIdFromCommandLine(); |
3fdb9e8c | 110 | if (network == CBaseChainParams::MAX_NETWORK_TYPES) |
84ce18ca | 111 | return false; |
84ce18ca | 112 | |
3fdb9e8c | 113 | SelectBaseParams(network); |
84ce18ca WL |
114 | return true; |
115 | } | |
96ff9d64 | 116 | |
20e01b1a PW |
117 | bool AreBaseParamsConfigured() |
118 | { | |
96ff9d64 WL |
119 | return pCurrentBaseParams != NULL; |
120 | } |