mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +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:
@@ -17,6 +17,7 @@
|
||||
#include <script/interpreter.h>
|
||||
#include <script/script.h>
|
||||
#include <uint256.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <util/strencodings.h>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -70,7 +71,7 @@ static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits
|
||||
class CMainParams : public CChainParams {
|
||||
public:
|
||||
CMainParams() {
|
||||
strNetworkID = CBaseChainParams::MAIN;
|
||||
m_chain_type = ChainType::MAIN;
|
||||
consensus.signet_blocks = false;
|
||||
consensus.signet_challenge.clear();
|
||||
consensus.nSubsidyHalvingInterval = 210000;
|
||||
@@ -192,7 +193,7 @@ public:
|
||||
class CTestNetParams : public CChainParams {
|
||||
public:
|
||||
CTestNetParams() {
|
||||
strNetworkID = CBaseChainParams::TESTNET;
|
||||
m_chain_type = ChainType::TESTNET;
|
||||
consensus.signet_blocks = false;
|
||||
consensus.signet_challenge.clear();
|
||||
consensus.nSubsidyHalvingInterval = 210000;
|
||||
@@ -328,7 +329,7 @@ public:
|
||||
vSeeds = *options.seeds;
|
||||
}
|
||||
|
||||
strNetworkID = CBaseChainParams::SIGNET;
|
||||
m_chain_type = ChainType::SIGNET;
|
||||
consensus.signet_blocks = true;
|
||||
consensus.signet_challenge.assign(bin.begin(), bin.end());
|
||||
consensus.nSubsidyHalvingInterval = 210000;
|
||||
@@ -397,7 +398,7 @@ class CRegTestParams : public CChainParams
|
||||
public:
|
||||
explicit CRegTestParams(const RegTestOptions& opts)
|
||||
{
|
||||
strNetworkID = CBaseChainParams::REGTEST;
|
||||
m_chain_type = ChainType::REGTEST;
|
||||
consensus.signet_blocks = false;
|
||||
consensus.signet_challenge.clear();
|
||||
consensus.nSubsidyHalvingInterval = 150;
|
||||
|
||||
Reference in New Issue
Block a user