Changeset View
Changeset View
Standalone View
Standalone View
src/util/system.cpp
Show First 20 Lines • Show All 1,024 Lines • ▼ Show 20 Lines | if (stream.good()) { | ||||
// ParseParameters() fails if a non-negated -includeconf is | // ParseParameters() fails if a non-negated -includeconf is | ||||
// passed on the command-line | // passed on the command-line | ||||
assert(it->second.empty()); | assert(it->second.empty()); | ||||
use_conf_file = false; | use_conf_file = false; | ||||
} | } | ||||
} | } | ||||
if (use_conf_file) { | if (use_conf_file) { | ||||
std::string chain_id = GetChainName(); | std::string chain_id = GetChainName(); | ||||
std::vector<std::string> includeconf(GetArgs("-includeconf")); | std::vector<std::string> conf_file_names(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( | std::vector<std::string> includeconf_net( | ||||
GetArgs(std::string("-") + chain_id + ".includeconf")); | GetArgs(std::string("-") + chain_id + ".includeconf")); | ||||
includeconf.insert(includeconf.end(), includeconf_net.begin(), | conf_file_names.insert(conf_file_names.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("-") + chain_id + | m_config_args.erase(std::string("-") + chain_id + | ||||
".includeconf"); | ".includeconf"); | ||||
} | } | ||||
for (const std::string &to_include : includeconf) { | for (const std::string &conf_file_name : conf_file_names) { | ||||
fsbridge::ifstream include_config(GetConfigFile(to_include)); | fsbridge::ifstream conf_file_stream( | ||||
if (include_config.good()) { | GetConfigFile(conf_file_name)); | ||||
if (!ReadConfigStream(include_config, to_include, error, | if (conf_file_stream.good()) { | ||||
ignore_invalid_keys)) { | if (!ReadConfigStream(conf_file_stream, conf_file_name, | ||||
error, ignore_invalid_keys)) { | |||||
return false; | return false; | ||||
} | } | ||||
LogPrintf("Included configuration file %s\n", | LogPrintf("Included configuration file %s\n", | ||||
to_include.c_str()); | conf_file_name); | ||||
} else { | } else { | ||||
error = | error = "Failed to include configuration file " + | ||||
"Failed to include configuration file " + to_include; | conf_file_name; | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
// Warn about recursive -includeconf | // Warn about recursive -includeconf | ||||
includeconf = GetArgs("-includeconf"); | conf_file_names = GetArgs("-includeconf"); | ||||
{ | { | ||||
std::vector<std::string> includeconf_net( | std::vector<std::string> includeconf_net( | ||||
GetArgs(std::string("-") + chain_id + ".includeconf")); | GetArgs(std::string("-") + chain_id + ".includeconf")); | ||||
includeconf.insert(includeconf.end(), includeconf_net.begin(), | conf_file_names.insert(conf_file_names.end(), | ||||
includeconf_net.begin(), | |||||
includeconf_net.end()); | includeconf_net.end()); | ||||
std::string chain_id_final = GetChainName(); | std::string chain_id_final = GetChainName(); | ||||
if (chain_id_final != chain_id) { | if (chain_id_final != chain_id) { | ||||
// Also warn about recursive includeconf for the chain that | // Also warn about recursive includeconf for the chain that | ||||
// was specified in one of the includeconfs | // was specified in one of the includeconfs | ||||
includeconf_net = GetArgs(std::string("-") + | includeconf_net = GetArgs(std::string("-") + | ||||
chain_id_final + ".includeconf"); | chain_id_final + ".includeconf"); | ||||
includeconf.insert(includeconf.end(), | conf_file_names.insert(conf_file_names.end(), | ||||
includeconf_net.begin(), | includeconf_net.begin(), | ||||
includeconf_net.end()); | includeconf_net.end()); | ||||
} | } | ||||
} | } | ||||
for (const std::string &to_include : includeconf) { | for (const std::string &conf_file_name : conf_file_names) { | ||||
tfm::format( | tfm::format(std::cerr, | ||||
std::cerr, | "warning: -includeconf cannot be used from " | ||||
"warning: -includeconf cannot be used from included " | "included files; ignoring -includeconf=%s\n", | ||||
"files; ignoring -includeconf=%s\n", | conf_file_name); | ||||
to_include.c_str()); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
// If datadir is changed in .conf file: | // If datadir is changed in .conf file: | ||||
ClearDatadirCache(); | ClearDatadirCache(); | ||||
if (!CheckDataDirOption()) { | if (!CheckDataDirOption()) { | ||||
error = strprintf("specified data directory \"%s\" does not exist.", | error = strprintf("specified data directory \"%s\" does not exist.", | ||||
▲ Show 20 Lines • Show All 310 Lines • Show Last 20 Lines |