Use ArgsManager::NETWORK_ONLY flag

This commit is contained in:
Hennadii Stepanov
2019-07-27 12:37:09 +03:00
parent 9a12733508
commit dde80c272a
7 changed files with 21 additions and 25 deletions

View File

@@ -307,18 +307,7 @@ static void InterpretOption(std::string key, std::string val, std::map<std::stri
args[key].push_back(val);
}
ArgsManager::ArgsManager() :
/* These options would cause cross-contamination if values for
* mainnet were used while running on regtest/testnet (or vice-versa).
* Setting them as section_only_args ensures that sharing a config file
* between mainnet and regtest/testnet won't cause problems due to these
* parameters by accident. */
m_network_only_args{
"-addnode", "-connect",
"-port", "-bind",
"-rpcport", "-rpcbind",
"-wallet",
}
ArgsManager::ArgsManager()
{
// nothing to do
}
@@ -546,11 +535,16 @@ void ArgsManager::AddArg(const std::string& name, const std::string& help, unsig
if (eq_index == std::string::npos) {
eq_index = name.size();
}
std::string arg_name = name.substr(0, eq_index);
LOCK(cs_args);
std::map<std::string, Arg>& arg_map = m_available_args[cat];
auto ret = arg_map.emplace(name.substr(0, eq_index), Arg{name.substr(eq_index, name.size() - eq_index), help, flags});
auto ret = arg_map.emplace(arg_name, Arg{name.substr(eq_index, name.size() - eq_index), help, flags});
assert(ret.second); // Make sure an insertion actually happened
if (flags & ArgsManager::NETWORK_ONLY) {
m_network_only_args.emplace(arg_name);
}
}
void ArgsManager::AddHiddenArgs(const std::vector<std::string>& names)