Changeset View
Changeset View
Standalone View
Standalone View
src/util/system.cpp
Show First 20 Lines • Show All 439 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
} | } | ||||
// we do not allow -includeconf from command line, so we clear it here | // we do not allow -includeconf from command line, so we clear it here | ||||
auto it = m_override_args.find("-includeconf"); | auto it = m_override_args.find("-includeconf"); | ||||
if (it != m_override_args.end()) { | if (it != m_override_args.end()) { | ||||
if (it->second.size() > 0) { | if (it->second.size() > 0) { | ||||
for (const auto &ic : it->second) { | for (const auto &ic : it->second) { | ||||
fprintf(stderr, | error += "-includeconf cannot be used from commandline; " | ||||
"warning: -includeconf cannot be used from " | "-includeconf=" + | ||||
"commandline; ignoring -includeconf=%s\n", | ic + "\n"; | ||||
ic.c_str()); | |||||
} | } | ||||
m_override_args.erase(it); | return false; | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool ArgsManager::IsArgKnown(const std::string &key) const { | bool ArgsManager::IsArgKnown(const std::string &key) const { | ||||
size_t option_index = key.find('.'); | size_t option_index = key.find('.'); | ||||
std::string arg_no_net; | std::string arg_no_net; | ||||
▲ Show 20 Lines • Show All 466 Lines • ▼ Show 20 Lines | if (stream.good()) { | ||||
// that means the user passed '-noincludeconf' on the command line, in | // that means the user passed '-noincludeconf' on the command line, in | ||||
// which case we should not include anything | // which case we should not include anything | ||||
bool emptyIncludeConf; | bool emptyIncludeConf; | ||||
{ | { | ||||
LOCK(cs_args); | LOCK(cs_args); | ||||
emptyIncludeConf = m_override_args.count("-includeconf") == 0; | emptyIncludeConf = m_override_args.count("-includeconf") == 0; | ||||
} | } | ||||
if (emptyIncludeConf) { | if (emptyIncludeConf) { | ||||
std::string chain_id = GetChainName(); | |||||
std::vector<std::string> includeconf(GetArgs("-includeconf")); | std::vector<std::string> includeconf(GetArgs("-includeconf")); | ||||
{ | { | ||||
// We haven't set m_network yet (that happens in | // We haven't set m_network yet (that happens in | ||||
// SelectParams()), so manually check for network.includeconf | // SelectParams()), so manually check for network.includeconf | ||||
// args. | // args. | ||||
std::vector<std::string> includeconf_net(GetArgs( | std::vector<std::string> includeconf_net( | ||||
std::string("-") + GetChainName() + ".includeconf")); | GetArgs(std::string("-") + chain_id + ".includeconf")); | ||||
includeconf.insert(includeconf.end(), includeconf_net.begin(), | includeconf.insert(includeconf.end(), includeconf_net.begin(), | ||||
includeconf_net.end()); | includeconf_net.end()); | ||||
} | } | ||||
// Remove -includeconf from configuration, so we can warn about | // Remove -includeconf from configuration, so we can warn about | ||||
// recursion later | // recursion later | ||||
{ | { | ||||
LOCK(cs_args); | LOCK(cs_args); | ||||
m_config_args.erase("-includeconf"); | m_config_args.erase("-includeconf"); | ||||
m_config_args.erase(std::string("-") + GetChainName() + | m_config_args.erase(std::string("-") + chain_id + | ||||
".includeconf"); | ".includeconf"); | ||||
} | } | ||||
for (const std::string &to_include : includeconf) { | for (const std::string &to_include : includeconf) { | ||||
fs::ifstream include_config(GetConfigFile(to_include)); | fs::ifstream include_config(GetConfigFile(to_include)); | ||||
if (include_config.good()) { | if (include_config.good()) { | ||||
if (!ReadConfigStream(include_config, error, | if (!ReadConfigStream(include_config, error, | ||||
ignore_invalid_keys)) { | ignore_invalid_keys)) { | ||||
return false; | return false; | ||||
} | } | ||||
LogPrintf("Included configuration file %s\n", | LogPrintf("Included configuration file %s\n", | ||||
to_include.c_str()); | to_include.c_str()); | ||||
} else { | } else { | ||||
fprintf(stderr, "Failed to include configuration file %s\n", | error = | ||||
to_include.c_str()); | "Failed to include configuration file " + to_include; | ||||
return false; | |||||
} | } | ||||
} | } | ||||
// Warn about recursive -includeconf | // Warn about recursive -includeconf | ||||
includeconf = GetArgs("-includeconf"); | includeconf = GetArgs("-includeconf"); | ||||
{ | { | ||||
std::vector<std::string> includeconf_net(GetArgs( | std::vector<std::string> includeconf_net( | ||||
std::string("-") + GetChainName() + ".includeconf")); | GetArgs(std::string("-") + chain_id + ".includeconf")); | ||||
includeconf.insert(includeconf.end(), includeconf_net.begin(), | includeconf.insert(includeconf.end(), includeconf_net.begin(), | ||||
includeconf_net.end()); | includeconf_net.end()); | ||||
std::string chain_id_final = GetChainName(); | |||||
if (chain_id_final != chain_id) { | |||||
// Also warn about recursive includeconf for the chain that | |||||
// was specified in one of the includeconfs | |||||
includeconf_net = GetArgs(std::string("-") + | |||||
chain_id_final + ".includeconf"); | |||||
includeconf.insert(includeconf.end(), | |||||
includeconf_net.begin(), | |||||
includeconf_net.end()); | |||||
} | |||||
} | } | ||||
for (const std::string &to_include : includeconf) { | for (const std::string &to_include : includeconf) { | ||||
fprintf(stderr, | fprintf(stderr, | ||||
"warning: -includeconf cannot be used from included " | "warning: -includeconf cannot be used from included " | ||||
"files; ignoring -includeconf=%s\n", | "files; ignoring -includeconf=%s\n", | ||||
to_include.c_str()); | to_include.c_str()); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 346 Lines • Show Last 20 Lines |