Line data Source code
1 : // Copyright (c) 2014 The Bitcoin Core developers
2 : // Distributed under the MIT software license, see the accompanying
3 : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 :
5 : #ifndef BITCOIN_CHAINPARAMSBASE_H
6 : #define BITCOIN_CHAINPARAMSBASE_H
7 :
8 : #include <string>
9 : #include <vector>
10 :
11 : /**
12 : * CBaseChainParams defines the base parameters (shared between bitcoin-cli and bitcoind)
13 : * of a given instance of the Bitcoin system.
14 : */
15 1218 : class CBaseChainParams
16 : {
17 : public:
18 : enum Network {
19 : MAIN,
20 : TESTNET,
21 : REGTEST,
22 :
23 : MAX_NETWORK_TYPES
24 : };
25 :
26 120 : const std::string& DataDir() const { return strDataDir; }
27 0 : int RPCPort() const { return nRPCPort; }
28 :
29 : protected:
30 812 : CBaseChainParams() {}
31 :
32 : int nRPCPort;
33 : std::string strDataDir;
34 : };
35 :
36 : /**
37 : * Return the currently selected parameters. This won't change after app
38 : * startup, except for unit tests.
39 : */
40 : const CBaseChainParams& BaseParams();
41 :
42 : /** Sets the params returned by Params() to those for the given network. */
43 : void SelectBaseParams(CBaseChainParams::Network network);
44 :
45 : /**
46 : * Looks for -regtest or -testnet and returns the appropriate Network ID.
47 : * Returns MAX_NETWORK_TYPES if an invalid combination is given.
48 : */
49 : CBaseChainParams::Network NetworkIdFromCommandLine();
50 :
51 : /**
52 : * Calls NetworkIdFromCommandLine() and then calls SelectParams as appropriate.
53 : * Returns false if an invalid combination is given.
54 : */
55 : bool SelectBaseParamsFromCommandLine();
56 :
57 : /**
58 : * Return true if SelectBaseParamsFromCommandLine() has been called to select
59 : * a network.
60 : */
61 : bool AreBaseParamsConfigured();
62 :
63 : #endif // BITCOIN_CHAINPARAMSBASE_H
|