Changeset View
Changeset View
Standalone View
Standalone View
src/util/system.cpp
Show First 20 Lines • Show All 331 Lines • ▼ Show 20 Lines | if (key.substr(option_index, 2) == "no") { | ||||
} else { | } else { | ||||
args[key].clear(); | args[key].clear(); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
args[key].push_back(val); | args[key].push_back(val); | ||||
} | } | ||||
ArgsManager::ArgsManager() | 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", | |||||
} { | |||||
// nothing to do | // nothing to do | ||||
} | } | ||||
const std::set<std::string> ArgsManager::GetUnsuitableSectionOnlyArgs() const { | const std::set<std::string> ArgsManager::GetUnsuitableSectionOnlyArgs() const { | ||||
std::set<std::string> unsuitables; | std::set<std::string> unsuitables; | ||||
LOCK(cs_args); | LOCK(cs_args); | ||||
▲ Show 20 Lines • Show All 270 Lines • ▼ Show 20 Lines | |||||
void ArgsManager::AddArg(const std::string &name, const std::string &help, | void ArgsManager::AddArg(const std::string &name, const std::string &help, | ||||
unsigned int flags, const OptionsCategory &cat) { | unsigned int flags, const OptionsCategory &cat) { | ||||
// Split arg name from its help param | // Split arg name from its help param | ||||
size_t eq_index = name.find('='); | size_t eq_index = name.find('='); | ||||
if (eq_index == std::string::npos) { | if (eq_index == std::string::npos) { | ||||
eq_index = name.size(); | eq_index = name.size(); | ||||
} | } | ||||
std::string arg_name = name.substr(0, eq_index); | |||||
LOCK(cs_args); | LOCK(cs_args); | ||||
std::map<std::string, Arg> &arg_map = m_available_args[cat]; | std::map<std::string, Arg> &arg_map = m_available_args[cat]; | ||||
auto ret = arg_map.emplace( | auto ret = arg_map.emplace( | ||||
name.substr(0, eq_index), | arg_name, | ||||
Arg{name.substr(eq_index, name.size() - eq_index), help, flags}); | Arg{name.substr(eq_index, name.size() - eq_index), help, flags}); | ||||
// Make sure an insertion actually happened. | // Make sure an insertion actually happened. | ||||
assert(ret.second); | assert(ret.second); | ||||
if (flags & ArgsManager::NETWORK_ONLY) { | |||||
m_network_only_args.emplace(arg_name); | |||||
} | |||||
} | } | ||||
void ArgsManager::AddHiddenArgs(const std::vector<std::string> &names) { | void ArgsManager::AddHiddenArgs(const std::vector<std::string> &names) { | ||||
for (const std::string &name : names) { | for (const std::string &name : names) { | ||||
AddArg(name, "", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); | AddArg(name, "", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 735 Lines • Show Last 20 Lines |