Skip to content

Commit 087c5d2

Browse files
committed
ReadConfigStream: assume the stream is good
1 parent 6d5815a commit 087c5d2

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/util.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -737,31 +737,31 @@ fs::path GetConfigFile(const std::string& confPath)
737737

738738
void ArgsManager::ReadConfigStream(std::istream& stream)
739739
{
740-
if (!stream.good())
741-
return; // No bitcoin.conf file is OK
740+
LOCK(cs_args);
742741

743-
{
744-
LOCK(cs_args);
745-
std::set<std::string> setOptions;
746-
setOptions.insert("*");
742+
std::set<std::string> setOptions;
743+
setOptions.insert("*");
747744

748-
for (boost::program_options::detail::config_file_iterator it(stream, setOptions), end; it != end; ++it)
749-
{
750-
// Don't overwrite existing settings so command line settings override bitcoin.conf
751-
std::string strKey = std::string("-") + it->string_key;
752-
std::string strValue = it->value[0];
753-
InterpretNegatedOption(strKey, strValue);
754-
if (mapArgs.count(strKey) == 0)
755-
mapArgs[strKey] = strValue;
756-
mapMultiArgs[strKey].push_back(strValue);
757-
}
745+
for (boost::program_options::detail::config_file_iterator it(stream, setOptions), end; it != end; ++it)
746+
{
747+
// Don't overwrite existing settings so command line settings override bitcoin.conf
748+
std::string strKey = std::string("-") + it->string_key;
749+
std::string strValue = it->value[0];
750+
InterpretNegatedOption(strKey, strValue);
751+
if (mapArgs.count(strKey) == 0)
752+
mapArgs[strKey] = strValue;
753+
mapMultiArgs[strKey].push_back(strValue);
758754
}
759755
}
760756

761757
void ArgsManager::ReadConfigFile(const std::string& confPath)
762758
{
763759
fs::ifstream stream(GetConfigFile(confPath));
764-
ReadConfigStream(stream);
760+
761+
// ok to not have a config file
762+
if (stream.good()) {
763+
ReadConfigStream(stream);
764+
}
765765

766766
// If datadir is changed in .conf file:
767767
ClearDatadirCache();

0 commit comments

Comments
 (0)