aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2018-04-04 18:09:00 +1000
committerAnthony Towns <aj@erisian.com.au>2018-04-11 23:15:28 +1000
commit005ad266491f43d7a9bfd959396037416cb32a55 (patch)
tree3c099ab828484ec5299c38754b25939347ef3c53
parent608415d4e6c6518aed248f33a58e07ba1e3df4c0 (diff)
ArgsManager: special handling for -regtest and -testnet
-rw-r--r--src/util.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 4101173091..1fb40ae7a1 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -537,6 +537,22 @@ public:
return found_result;
}
+
+ /* 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)
+ {
+ std::pair<bool,std::string> found_result(false,std::string());
+ found_result = GetArgHelper(am.m_override_args, net_arg, true);
+ if (!found_result.first) {
+ found_result = GetArgHelper(am.m_config_args, net_arg, true);
+ if (!found_result.first) {
+ return false; // not set
+ }
+ }
+ return InterpretBool(found_result.second); // is set, so evaluate
+ }
};
/**
@@ -950,8 +966,8 @@ void ArgsManager::ReadConfigFile(const std::string& confPath)
std::string ArgsManager::GetChainName() const
{
- bool fRegTest = GetBoolArg("-regtest", false);
- bool fTestNet = GetBoolArg("-testnet", false);
+ bool fRegTest = ArgsManagerHelper::GetNetBoolArg(*this, "-regtest");
+ bool fTestNet = ArgsManagerHelper::GetNetBoolArg(*this, "-testnet");
if (fTestNet && fRegTest)
throw std::runtime_error("Invalid combination of -regtest and -testnet.");