Line data Source code
1 : // Copyright (c) 2014-2020 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 <util/chaintype.h> 9 : 10 : #include <memory> 11 : #include <string> 12 : 13 : class ArgsManager; 14 : 15 : /** 16 : * CBaseChainParams defines the base parameters (shared between bitcoin-cli and bitcoind) 17 : * of a given instance of the Bitcoin system. 18 : */ 19 : class CBaseChainParams 20 : { 21 : public: 22 253 : const std::string& DataDir() const { return strDataDir; } 23 4 : uint16_t RPCPort() const { return m_rpc_port; } 24 4 : uint16_t OnionServiceTargetPort() const { return m_onion_service_target_port; } 25 : 26 : CBaseChainParams() = delete; 27 5 : CBaseChainParams(const std::string& data_dir, uint16_t rpc_port, uint16_t onion_service_target_port) 28 5 : : m_rpc_port(rpc_port), m_onion_service_target_port(onion_service_target_port), strDataDir(data_dir) {} 29 : 30 : private: 31 : const uint16_t m_rpc_port; 32 : const uint16_t m_onion_service_target_port; 33 : std::string strDataDir; 34 : }; 35 : 36 : /** 37 : * Creates and returns a std::unique_ptr<CBaseChainParams> of the chosen chain. 38 : */ 39 : std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const ChainType chain); 40 : 41 : /** 42 : *Set the arguments for chainparams 43 : */ 44 : void SetupChainParamsBaseOptions(ArgsManager& argsman); 45 : 46 : /** 47 : * Return the currently selected parameters. This won't change after app 48 : * startup, except for unit tests. 49 : */ 50 : const CBaseChainParams& BaseParams(); 51 : 52 : /** Sets the params returned by Params() to those for the given chain. */ 53 : void SelectBaseParams(const ChainType chain); 54 : 55 : #endif // BITCOIN_CHAINPARAMSBASE_H