aboutsummaryrefslogtreecommitdiff
path: root/src/chainparamsbase.h
diff options
context:
space:
mode:
authorTheCharlatan <seb.kung@gmail.com>2023-04-17 22:20:59 +0200
committerTheCharlatan <seb.kung@gmail.com>2023-05-09 15:49:14 +0200
commitba8fc7d788932b25864fb260ca14983aa2398c23 (patch)
tree3049d9b5282c243faf7e0ab1e7d2a7ee17937a36 /src/chainparamsbase.h
parent401453df419af35957ec711423ac3d93ad512fe8 (diff)
downloadbitcoin-ba8fc7d788932b25864fb260ca14983aa2398c23.tar.xz
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.
Diffstat (limited to 'src/chainparamsbase.h')
-rw-r--r--src/chainparamsbase.h16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/chainparamsbase.h b/src/chainparamsbase.h
index d593cff722..73e449d11b 100644
--- a/src/chainparamsbase.h
+++ b/src/chainparamsbase.h
@@ -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