aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2018-03-29 15:02:00 +1000
committerAnthony Towns <aj@erisian.com.au>2018-04-06 04:46:32 +1000
commit6d5815aad0ee0614972f288cbd1c68386e801d5d (patch)
treeddbe3bab22c6b8c98ccef97ef17ab88fa3b5c3c1 /src
parent834d3034158b6b199779d5dd218e15604798ca06 (diff)
downloadbitcoin-6d5815aad0ee0614972f288cbd1c68386e801d5d.tar.xz
Separate out ReadConfigStream from ReadConfigFile
Diffstat (limited to 'src')
-rw-r--r--src/util.cpp14
-rw-r--r--src/util.h2
2 files changed, 12 insertions, 4 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 6dfb12f8e7..11b83798b8 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -735,10 +735,9 @@ fs::path GetConfigFile(const std::string& confPath)
return AbsPathForConfigVal(fs::path(confPath), false);
}
-void ArgsManager::ReadConfigFile(const std::string& confPath)
+void ArgsManager::ReadConfigStream(std::istream& stream)
{
- fs::ifstream streamConfig(GetConfigFile(confPath));
- if (!streamConfig.good())
+ if (!stream.good())
return; // No bitcoin.conf file is OK
{
@@ -746,7 +745,7 @@ void ArgsManager::ReadConfigFile(const std::string& confPath)
std::set<std::string> setOptions;
setOptions.insert("*");
- for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it)
+ 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;
@@ -757,6 +756,13 @@ void ArgsManager::ReadConfigFile(const std::string& confPath)
mapMultiArgs[strKey].push_back(strValue);
}
}
+}
+
+void ArgsManager::ReadConfigFile(const std::string& confPath)
+{
+ fs::ifstream stream(GetConfigFile(confPath));
+ ReadConfigStream(stream);
+
// If datadir is changed in .conf file:
ClearDatadirCache();
if (!fs::is_directory(GetDataDir(false))) {
diff --git a/src/util.h b/src/util.h
index 5afe80cb06..bfd3184ac2 100644
--- a/src/util.h
+++ b/src/util.h
@@ -228,6 +228,8 @@ protected:
std::map<std::string, std::vector<std::string>> mapMultiArgs;
std::unordered_set<std::string> m_negated_args;
+ void ReadConfigStream(std::istream& stream);
+
public:
void ParseParameters(int argc, const char*const argv[]);
void ReadConfigFile(const std::string& confPath);