Skip to content

Commit

Permalink
Add DEFAULT chain and set to liquidv1
Browse files Browse the repository at this point in the history
This fixes f.e. that when arguments are set in CLI or the config file
without a network attached (`port` instead of `liquidv1.port`), they
will now be assigned to the liquidv1 instead of Bitcoin mainnet.
  • Loading branch information
stevenroose committed Jan 29, 2020
1 parent c7ee0ac commit 36ac130
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const std::string CBaseChainParams::TESTNET = "test";
const std::string CBaseChainParams::REGTEST = "regtest";
const std::string CBaseChainParams::LIQUID1 = "liquidv1";

const std::string CBaseChainParams::DEFAULT = CBaseChainParams::LIQUID1;

void SetupChainParamsBaseOptions()
{
gArgs.AddArg("-chain=<chain>", "Use the chain <chain> (default: main). Reserved values: main, test, regtest", false, OptionsCategory::CHAINPARAMS);
Expand Down
2 changes: 2 additions & 0 deletions src/chainparamsbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class CBaseChainParams
static const std::string REGTEST;
static const std::string LIQUID1;

static const std::string DEFAULT;

const std::string& DataDir() const { return strDataDir; }
int RPCPort() const { return nRPCPort; }
int MainchainRPCPort() const { return nMainchainRPCPort; }
Expand Down
6 changes: 4 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,12 @@ void SetupServerArgs()
SetupHelpOptions(gArgs);
gArgs.AddArg("-help-debug", "Print help message with debugging options and exit", false, OptionsCategory::DEBUG_TEST); // server-only for now

const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN);
const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::DEFAULT);
const auto mainnetBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN);
const auto testnetBaseParams = CreateBaseChainParams(CBaseChainParams::TESTNET);
const auto regtestBaseParams = CreateBaseChainParams(CBaseChainParams::REGTEST);
const auto defaultChainParams = CreateChainParams(CBaseChainParams::MAIN);
const auto defaultChainParams = CreateChainParams(CBaseChainParams::DEFAULT);
const auto mainnetChainParams = CreateChainParams(CBaseChainParams::MAIN);
const auto testnetChainParams = CreateChainParams(CBaseChainParams::TESTNET);
const auto regtestChainParams = CreateChainParams(CBaseChainParams::REGTEST);

Expand Down
2 changes: 1 addition & 1 deletion src/test/util_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ BOOST_AUTO_TEST_CASE(util_ReadConfigStream)
test_args.SetNetworkOnlyArg("-ccc");
test_args.SetNetworkOnlyArg("-h");

test_args.SelectConfigNetwork(CBaseChainParams::MAIN);
test_args.SelectConfigNetwork(CBaseChainParams::DEFAULT);
BOOST_CHECK(test_args.GetArg("-d", "xxx") == "e");
BOOST_CHECK(test_args.GetArgs("-ccc").size() == 2);
BOOST_CHECK(test_args.GetArg("-h", "xxx") == "0");
Expand Down
4 changes: 2 additions & 2 deletions src/util/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class ArgsManagerHelper {
* See also comments around ArgsManager::ArgsManager() below. */
static inline bool UseDefaultSection(const ArgsManager& am, const std::string& arg) EXCLUSIVE_LOCKS_REQUIRED(am.cs_args)
{
return (am.m_network == CBaseChainParams::MAIN || am.m_network_only_args.count(arg) == 0);
return (am.m_network == CBaseChainParams::DEFAULT || am.m_network_only_args.count(arg) == 0);
}

/** Convert regular argument into the network-specific setting */
Expand Down Expand Up @@ -336,7 +336,7 @@ const std::set<std::string> ArgsManager::GetUnsuitableSectionOnlyArgs() const
if (m_network.empty()) return std::set<std::string> {};

// if it's okay to use the default section for this network, don't worry
if (m_network == CBaseChainParams::MAIN) return std::set<std::string> {};
if (m_network == CBaseChainParams::DEFAULT) return std::set<std::string> {};

for (const auto& arg : m_network_only_args) {
std::pair<bool, std::string> found_result;
Expand Down

0 comments on commit 36ac130

Please sign in to comment.