Skip to content

Commit

Permalink
Fix argument handling for devnets (#3549)
Browse files Browse the repository at this point in the history
* Use "devnet" instead of "dev" for network id

Otherwise one would have to use "dev.port=123" in configs, which might
be confusing as we usually name such networks "devnet".

* Fix ArgsManager::GetChainName to work with devnets again

-devnet is not a boolean arg, but a string. So we have to check for
existence only.
  • Loading branch information
codablock authored Jun 24, 2020
1 parent de099fe commit aab4852
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ class CTestNetParams : public CChainParams {
class CDevNetParams : public CChainParams {
public:
CDevNetParams() {
strNetworkID = "dev";
strNetworkID = "devnet";
consensus.nSubsidyHalvingInterval = 210240;
consensus.nMasternodePaymentsStartBlock = 4010; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
consensus.nMasternodePaymentsIncreaseBlock = 4030;
Expand Down
2 changes: 1 addition & 1 deletion src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

const std::string CBaseChainParams::MAIN = "main";
const std::string CBaseChainParams::TESTNET = "test";
const std::string CBaseChainParams::DEVNET = "dev";
const std::string CBaseChainParams::DEVNET = "devnet";
const std::string CBaseChainParams::REGTEST = "regtest";

void AppendParamsHelpMessages(std::string& strUsage, bool debugHelp)
Expand Down
2 changes: 1 addition & 1 deletion src/qt/networkstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static const struct {
} network_styles[] = {
{"main", QAPP_APP_NAME_DEFAULT, 0, 0, ""},
{"test", QAPP_APP_NAME_TESTNET, 190, 20, QT_TRANSLATE_NOOP("SplashScreen", "[testnet]")},
{"dev", QAPP_APP_NAME_DEVNET, 190, 20, "[devnet: %s]"},
{"devnet", QAPP_APP_NAME_DEVNET, 190, 20, "[devnet: %s]"},
{"regtest", QAPP_APP_NAME_REGTEST, 160, 30, "[regtest]"}
};
static const unsigned network_styles_count = sizeof(network_styles)/sizeof(*network_styles);
Expand Down
10 changes: 5 additions & 5 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ class ArgsManagerHelper {
/* Special test for -testnet and -regtest args, because we
* don't want to be confused by craziness like "[regtest] testnet=1"
*/
static inline bool GetNetBoolArg(const ArgsManager &am, const std::string& net_arg)
static inline bool GetNetBoolArg(const ArgsManager &am, const std::string& net_arg, bool interpret_bool)
{
std::pair<bool,std::string> found_result(false,std::string());
found_result = GetArgHelper(am.m_override_args, net_arg, true);
Expand All @@ -630,7 +630,7 @@ class ArgsManagerHelper {
return false; // not set
}
}
return InterpretBool(found_result.second); // is set, so evaluate
return !interpret_bool || InterpretBool(found_result.second); // is set, so evaluate
}
};

Expand Down Expand Up @@ -1031,9 +1031,9 @@ void ArgsManager::ReadConfigFile(const std::string& confPath)

std::string ArgsManager::GetChainName() const
{
bool fRegTest = ArgsManagerHelper::GetNetBoolArg(*this, "-regtest");
bool fDevNet = ArgsManagerHelper::GetNetBoolArg(*this, "-devnet");
bool fTestNet = ArgsManagerHelper::GetNetBoolArg(*this, "-testnet");
bool fRegTest = ArgsManagerHelper::GetNetBoolArg(*this, "-regtest", true);
bool fDevNet = ArgsManagerHelper::GetNetBoolArg(*this, "-devnet", false);
bool fTestNet = ArgsManagerHelper::GetNetBoolArg(*this, "-testnet", true);

int nameParamsCount = (fRegTest ? 1 : 0) + (fDevNet ? 1 : 0) + (fTestNet ? 1 : 0);
if (nameParamsCount > 1)
Expand Down

0 comments on commit aab4852

Please sign in to comment.