Line data Source code
1 : // Copyright (c) 2014-2021 The Bitcoin developers 2 : // Copyright (c) 2017-2021 The PIVX Core developers 3 : // Distributed under the MIT software license, see the accompanying 4 : // file COPYING or http://www.opensource.org/licenses/mit-license.php. 5 : 6 : #ifndef PIVX_CHAINPARAMSBASE_H 7 : #define PIVX_CHAINPARAMSBASE_H 8 : 9 : #include <memory> 10 : #include <string> 11 : #include <vector> 12 : 13 : /** 14 : * CBaseChainParams defines the base parameters (shared between pivx-cli and pivxd) 15 : * of a given instance of the Pivx system. 16 : */ 17 947 : class CBaseChainParams 18 : { 19 : public: 20 : ///@{ 21 : /** Chain name strings */ 22 : static const std::string MAIN; 23 : static const std::string TESTNET; 24 : static const std::string REGTEST; 25 : ///@} 26 : 27 1012 : const std::string& DataDir() const { return strDataDir; } 28 379 : int RPCPort() const { return nRPCPort; } 29 : 30 : CBaseChainParams() = delete; 31 947 : CBaseChainParams(const std::string& data_dir, int rpc_port) : nRPCPort(rpc_port), strDataDir(data_dir) {} 32 : 33 : private: 34 : int nRPCPort; 35 : std::string strDataDir; 36 : }; 37 : 38 : /** 39 : * Creates and returns a std::unique_ptr<CBaseChainParams> of the chosen chain. 40 : * @returns a CBaseChainParams* of the chosen chain. 41 : * @throws a std::runtime_error if the chain is not supported. 42 : */ 43 : std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain); 44 : 45 : /** 46 : * Append the help messages for the chainparams options to the 47 : * parameter string. 48 : */ 49 : void AppendParamsHelpMessages(std::string& strUsage, bool debugHelp=true); 50 : 51 : /** 52 : * Return the currently selected parameters. This won't change after app startup 53 : * startup, except for unit tests. 54 : */ 55 : const CBaseChainParams& BaseParams(); 56 : 57 : /** Sets the params returned by Params() to those for the given network. */ 58 : void SelectBaseParams(const std::string& chain); 59 : 60 : /** 61 : * Returns the appropriate chain name from the program arguments. 62 : * @return CBaseChainParams::MAX_NETWORK_TYPES if an invalid combination is given. CBaseChainParams::MAIN by default. 63 : */ 64 : std::string ChainNameFromCommandLine(); 65 : 66 : #endif // PIVX_CHAINPARAMSBASE_H