]> Git Repo - VerusCoin.git/blame - src/chainparamsbase.cpp
test
[VerusCoin.git] / src / chainparamsbase.cpp
CommitLineData
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
15class CBaseMainParams : public CBaseChainParams
16{
84ce18ca 17public:
20e01b1a
PW
18 CBaseMainParams()
19 {
94cc76bf 20 nRPCPort = 7771;
84ce18ca
WL
21 }
22};
23static CBaseMainParams mainParams;
24
f2e03ffa
MF
25/**
26 * Testnet (v3)
27 */
20e01b1a
PW
28class CBaseTestNetParams : public CBaseMainParams
29{
84ce18ca 30public:
20e01b1a
PW
31 CBaseTestNetParams()
32 {
94cc76bf 33 nRPCPort = 17771;
84ce18ca
WL
34 strDataDir = "testnet3";
35 }
36};
37static CBaseTestNetParams testNetParams;
38
f2e03ffa
MF
39/*
40 * Regression test
41 */
20e01b1a
PW
42class CBaseRegTestParams : public CBaseTestNetParams
43{
84ce18ca 44public:
20e01b1a
PW
45 CBaseRegTestParams()
46 {
84ce18ca
WL
47 strDataDir = "regtest";
48 }
49};
50static CBaseRegTestParams regTestParams;
51
f2e03ffa
MF
52/*
53 * Unit test
54 */
f0fd00cb
S
55class CBaseUnitTestParams : public CBaseMainParams
56{
57public:
58 CBaseUnitTestParams()
59 {
f0fd00cb
S
60 strDataDir = "unittest";
61 }
62};
63static CBaseUnitTestParams unitTestParams;
64
20e01b1a 65static CBaseChainParams* pCurrentBaseParams = 0;
84ce18ca 66
20e01b1a
PW
67const CBaseChainParams& BaseParams()
68{
93829088 69 if ( pCurrentBaseParams == 0 )
70 pCurrentBaseParams = &mainParams;
84ce18ca
WL
71 assert(pCurrentBaseParams);
72 return *pCurrentBaseParams;
73}
74
20e01b1a
PW
75void 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 = &regTestParams;
86 break;
87 default:
88 assert(false && "Unimplemented network");
89 return;
84ce18ca
WL
90 }
91}
92
b796cb08 93CBaseChainParams::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 107bool 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
117bool AreBaseParamsConfigured()
118{
96ff9d64
WL
119 return pCurrentBaseParams != NULL;
120}
This page took 0.139845 seconds and 4 git commands to generate.