diff options
author | Anthony Towns <aj@erisian.com.au> | 2018-03-29 15:03:00 +1000 |
---|---|---|
committer | Anthony Towns <aj@erisian.com.au> | 2018-04-06 04:46:32 +1000 |
commit | 087c5d204015e646d65696007415d6e998764631 (patch) | |
tree | ef411ea1e5b9f7d222cc5cd024a093c5bbfec5f3 | |
parent | 6d5815aad0ee0614972f288cbd1c68386e801d5d (diff) |
ReadConfigStream: assume the stream is good
-rw-r--r-- | src/util.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/util.cpp b/src/util.cpp index 11b83798b8..78df33e888 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -737,31 +737,31 @@ fs::path GetConfigFile(const std::string& confPath) void ArgsManager::ReadConfigStream(std::istream& stream) { - if (!stream.good()) - return; // No bitcoin.conf file is OK + LOCK(cs_args); - { - LOCK(cs_args); - std::set<std::string> setOptions; - setOptions.insert("*"); + 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); - } + 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); } } 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(); |