mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-10 12:43:30 +01:00
refactor: Replace string chain name constants with ChainTypes
This commit effectively moves the definition of these constants out of the chainparamsbase to their own file. Using the ChainType enums provides better type safety compared to passing around strings. The commit is part of an ongoing effort to decouple the libbitcoinkernel library from the ArgsManager and other functionality that should not be part of the kernel library.
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#ifndef BITCOIN_CHAINPARAMSBASE_H
|
||||
#define BITCOIN_CHAINPARAMSBASE_H
|
||||
|
||||
#include <util/chaintype.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -17,14 +19,6 @@ class ArgsManager;
|
||||
class CBaseChainParams
|
||||
{
|
||||
public:
|
||||
///@{
|
||||
/** Chain name strings */
|
||||
static const std::string MAIN;
|
||||
static const std::string TESTNET;
|
||||
static const std::string SIGNET;
|
||||
static const std::string REGTEST;
|
||||
///@}
|
||||
|
||||
const std::string& DataDir() const { return strDataDir; }
|
||||
uint16_t RPCPort() const { return m_rpc_port; }
|
||||
uint16_t OnionServiceTargetPort() const { return m_onion_service_target_port; }
|
||||
@@ -44,7 +38,7 @@ private:
|
||||
* @returns a CBaseChainParams* of the chosen chain.
|
||||
* @throws a std::runtime_error if the chain is not supported.
|
||||
*/
|
||||
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain);
|
||||
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const ChainType chain);
|
||||
|
||||
/**
|
||||
*Set the arguments for chainparams
|
||||
@@ -57,7 +51,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman);
|
||||
*/
|
||||
const CBaseChainParams& BaseParams();
|
||||
|
||||
/** Sets the params returned by Params() to those for the given network. */
|
||||
void SelectBaseParams(const std::string& chain);
|
||||
/** Sets the params returned by Params() to those for the given chain. */
|
||||
void SelectBaseParams(const ChainType chain);
|
||||
|
||||
#endif // BITCOIN_CHAINPARAMSBASE_H
|
||||
|
||||
Reference in New Issue
Block a user