Skip to content

Commit

Permalink
ReadConfigStream: assume the stream is good
Browse files Browse the repository at this point in the history
  • Loading branch information
ajtowns authored and random-zebra committed Apr 19, 2021
1 parent 56ea59e commit 23a4633
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,30 +502,30 @@ fs::path GetMasternodeConfigFile()

void ArgsManager::ReadConfigStream(std::istream& stream)
{
if (!stream.good())
return; // No pivx.conf file is OK

{
LOCK(cs_args);
std::set<std::string> setOptions;
setOptions.insert("*");

for (boost::program_options::detail::config_file_iterator it(stream, setOptions), end; it != end; ++it) {
// Don't overwrite existing settings so command line settings override bitcoin.conf
std::string strKey = std::string("-") + it->string_key;
std::string strValue = it->value[0];
InterpretNegatedOption(strKey, strValue);
if (mapArgs.count(strKey) == 0)
mapArgs[strKey] = strValue;
mapMultiArgs[strKey].push_back(strValue);
}
LOCK(cs_args);

std::set<std::string> setOptions;
setOptions.insert("*");

for (boost::program_options::detail::config_file_iterator it(stream, setOptions), end; it != end; ++it) {
// Don't overwrite existing settings so command line settings override pivx.conf
std::string strKey = std::string("-") + it->string_key;
std::string strValue = it->value[0];
InterpretNegatedOption(strKey, strValue);
if (mapArgs.count(strKey) == 0)
mapArgs[strKey] = strValue;
mapMultiArgs[strKey].push_back(strValue);
}
}

void ArgsManager::ReadConfigFile(const std::string& confPath)
{
fs::ifstream stream(GetConfigFile(confPath));
ReadConfigStream(stream);

// ok to not have a config file
if (stream.good()) {
ReadConfigStream(stream);
}

// If datadir is changed in .conf file:
ClearDatadirCache();
Expand Down

0 comments on commit 23a4633

Please sign in to comment.