Browse Source

Merge #8856: Globals: Decouple GetConfigFile and ReadConfigFile from global mapArgs

3450c18 Globals: Decouple GetConfigFile and ReadConfigFile from global mapArgs (Jorge Timón)
tags/v0.15.1
Wladimir J. van der Laan 4 years ago
parent
commit
a7e5cbb209
No account linked to committer's email address
6 changed files with 12 additions and 11 deletions
  1. 2
    2
      src/bitcoin-cli.cpp
  2. 1
    1
      src/bitcoind.cpp
  3. 1
    1
      src/init.cpp
  4. 1
    1
      src/qt/bitcoin.cpp
  5. 5
    4
      src/util.cpp
  6. 2
    2
      src/util.h

+ 2
- 2
src/bitcoin-cli.cpp View File

@@ -92,7 +92,7 @@ static bool AppInitRPC(int argc, char* argv[])
return false;
}
try {
ReadConfigFile(mapArgs, mapMultiArgs);
ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME), mapArgs, mapMultiArgs);
} catch (const std::exception& e) {
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
return false;
@@ -209,7 +209,7 @@ UniValue CallRPC(const string& strMethod, const UniValue& params)
if (!GetAuthCookie(&strRPCUserColonPass)) {
throw runtime_error(strprintf(
_("Could not locate RPC credentials. No authentication cookie could be found, and no rpcpassword is set in the configuration file (%s)"),
GetConfigFile().string().c_str()));
GetConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME)).string().c_str()));

}
} else {

+ 1
- 1
src/bitcoind.cpp View File

@@ -104,7 +104,7 @@ bool AppInit(int argc, char* argv[])
}
try
{
ReadConfigFile(mapArgs, mapMultiArgs);
ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME), mapArgs, mapMultiArgs);
} catch (const std::exception& e) {
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
return false;

+ 1
- 1
src/init.cpp View File

@@ -1064,7 +1064,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
LogPrintf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()));
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
LogPrintf("Using data directory %s\n", strDataDir);
LogPrintf("Using config file %s\n", GetConfigFile().string());
LogPrintf("Using config file %s\n", GetConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME)).string());
LogPrintf("Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD);

LogPrintf("Using %u threads for script verification\n", nScriptCheckThreads);

+ 1
- 1
src/qt/bitcoin.cpp View File

@@ -590,7 +590,7 @@ int main(int argc, char *argv[])
return 1;
}
try {
ReadConfigFile(mapArgs, mapMultiArgs);
ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME), mapArgs, mapMultiArgs);
} catch (const std::exception& e) {
QMessageBox::critical(0, QObject::tr(PACKAGE_NAME),
QObject::tr("Error: Cannot parse configuration file: %1. Only use key=value syntax.").arg(e.what()));

+ 5
- 4
src/util.cpp View File

@@ -518,19 +518,20 @@ void ClearDatadirCache()
pathCachedNetSpecific = boost::filesystem::path();
}

boost::filesystem::path GetConfigFile()
boost::filesystem::path GetConfigFile(const std::string& confPath)
{
boost::filesystem::path pathConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME));
boost::filesystem::path pathConfigFile(confPath);
if (!pathConfigFile.is_complete())
pathConfigFile = GetDataDir(false) / pathConfigFile;

return pathConfigFile;
}

void ReadConfigFile(map<string, string>& mapSettingsRet,
void ReadConfigFile(const std::string& confPath,
map<string, string>& mapSettingsRet,
map<string, vector<string> >& mapMultiSettingsRet)
{
boost::filesystem::ifstream streamConfig(GetConfigFile());
boost::filesystem::ifstream streamConfig(GetConfigFile(confPath));
if (!streamConfig.good())
return; // No bitcoin.conf file is OK


+ 2
- 2
src/util.h View File

@@ -102,12 +102,12 @@ bool TryCreateDirectory(const boost::filesystem::path& p);
boost::filesystem::path GetDefaultDataDir();
const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);
void ClearDatadirCache();
boost::filesystem::path GetConfigFile();
boost::filesystem::path GetConfigFile(const std::string& confPath);
#ifndef WIN32
boost::filesystem::path GetPidFile();
void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
#endif
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
void ReadConfigFile(const std::string& confPath, std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
#ifdef WIN32
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
#endif

Loading…
Cancel
Save