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