]> Git Repo - VerusCoin.git/blame - src/chainparamsbase.cpp
Fix exception
[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 */
54ab3b31 28class CBaseTestNetParams : public CBaseChainParams
20e01b1a 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 */
54ab3b31 42class CBaseRegTestParams : public CBaseChainParams
20e01b1a 43{
84ce18ca 44public:
20e01b1a
PW
45 CBaseRegTestParams()
46 {
54ab3b31 47 nRPCPort = 18232;
84ce18ca
WL
48 strDataDir = "regtest";
49 }
50};
51static CBaseRegTestParams regTestParams;
52
f2e03ffa
MF
53/*
54 * Unit test
55 */
f0fd00cb
S
56class CBaseUnitTestParams : public CBaseMainParams
57{
58public:
59 CBaseUnitTestParams()
60 {
f0fd00cb
S
61 strDataDir = "unittest";
62 }
63};
64static CBaseUnitTestParams unitTestParams;
65
20e01b1a 66static CBaseChainParams* pCurrentBaseParams = 0;
84ce18ca 67
20e01b1a
PW
68const CBaseChainParams& BaseParams()
69{
93829088 70 if ( pCurrentBaseParams == 0 )
71 pCurrentBaseParams = &mainParams;
84ce18ca
WL
72 assert(pCurrentBaseParams);
73 return *pCurrentBaseParams;
74}
75
20e01b1a
PW
76void SelectBaseParams(CBaseChainParams::Network network)
77{
84ce18ca 78 switch (network) {
20e01b1a
PW
79 case CBaseChainParams::MAIN:
80 pCurrentBaseParams = &mainParams;
81 break;
82 case CBaseChainParams::TESTNET:
83 pCurrentBaseParams = &testNetParams;
84 break;
85 case CBaseChainParams::REGTEST:
86 pCurrentBaseParams = &regTestParams;
87 break;
88 default:
89 assert(false && "Unimplemented network");
90 return;
84ce18ca
WL
91 }
92}
93
b796cb08 94CBaseChainParams::Network NetworkIdFromCommandLine()
20e01b1a 95{
84ce18ca
WL
96 bool fRegTest = GetBoolArg("-regtest", false);
97 bool fTestNet = GetBoolArg("-testnet", false);
98
3fdb9e8c 99 if (fTestNet && fRegTest)
b796cb08 100 return CBaseChainParams::MAX_NETWORK_TYPES;
3fdb9e8c 101 if (fRegTest)
b796cb08 102 return CBaseChainParams::REGTEST;
3fdb9e8c 103 if (fTestNet)
b796cb08 104 return CBaseChainParams::TESTNET;
105 return CBaseChainParams::MAIN;
3fdb9e8c 106}
107
ca3ce0fa 108bool SelectBaseParamsFromCommandLine()
3fdb9e8c 109{
b796cb08 110 CBaseChainParams::Network network = NetworkIdFromCommandLine();
3fdb9e8c 111 if (network == CBaseChainParams::MAX_NETWORK_TYPES)
84ce18ca 112 return false;
84ce18ca 113
3fdb9e8c 114 SelectBaseParams(network);
84ce18ca
WL
115 return true;
116}
96ff9d64 117
20e01b1a
PW
118bool AreBaseParamsConfigured()
119{
96ff9d64
WL
120 return pCurrentBaseParams != NULL;
121}
This page took 0.224961 seconds and 4 git commands to generate.