Skip to content

Commit 0bf2274

Browse files
committed
Added chaintype user-facing string display
1 parent fa7c283 commit 0bf2274

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/kernel/chainparams.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ class CChainParams
105105
uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
106106
/** Minimum free space (in GB) needed for data directory */
107107
uint64_t AssumedBlockchainSize() const { return m_assumed_blockchain_size; }
108-
/** Minimum free space (in GB) needed for data directory when pruned; Does not include prune target*/
108+
/** Minimum free space (in GB) needed for data directory when pruned; Does not include prune target */
109109
uint64_t AssumedChainStateSize() const { return m_assumed_chain_state_size; }
110110
/** Whether it is possible to mine blocks on demand (no retargeting) */
111111
bool MineBlocksOnDemand() const { return consensus.fPowNoRetargeting; }
112+
/** Return the chain type as a user-facing string */
113+
std::string GetChainTypeDisplayString() const { return ChainTypeToDisplayString(m_chain_type); }
112114
/** Return the chain type string */
113115
std::string GetChainTypeString() const { return ChainTypeToString(m_chain_type); }
114116
/** Return the chain type */

src/util/chaintype.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,18 @@ std::optional<ChainType> ChainTypeFromString(std::string_view chain)
4141
return std::nullopt;
4242
}
4343
}
44+
45+
std::string ChainTypeToDisplayString(ChainType chain)
46+
{
47+
switch (chain) {
48+
case ChainType::MAIN:
49+
return "Bitcoin";
50+
case ChainType::TESTNET:
51+
return "testnet";
52+
case ChainType::SIGNET:
53+
return "signet";
54+
case ChainType::REGTEST:
55+
return "regtest";
56+
}
57+
assert(false);
58+
}

src/util/chaintype.h

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ enum class ChainType {
1616
TESTNET4,
1717
};
1818

19+
std::string ChainTypeToDisplayString(ChainType chain);
20+
1921
std::string ChainTypeToString(ChainType chain);
2022

2123
std::optional<ChainType> ChainTypeFromString(std::string_view chain);

0 commit comments

Comments
 (0)