Browse Source

Globals: Decouple GetConfigFile and ReadConfigFile from global mapArgs

0.14
Jorge Timón 8 years ago
parent
commit
3450c18a12
No known key found for this signature in database
GPG Key ID: 8866C18EA1C944A2
  1. 4
      src/bitcoin-cli.cpp
  2. 2
      src/bitcoind.cpp
  3. 2
      src/init.cpp
  4. 2
      src/qt/bitcoin.cpp
  5. 9
      src/util.cpp
  6. 4
      src/util.h

4
src/bitcoin-cli.cpp

@ -92,7 +92,7 @@ static bool AppInitRPC(int argc, char* argv[]) @@ -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) @@ -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 {

2
src/bitcoind.cpp

@ -104,7 +104,7 @@ bool AppInit(int argc, char* argv[]) @@ -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;

2
src/init.cpp

@ -1064,7 +1064,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) @@ -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);

2
src/qt/bitcoin.cpp

@ -590,7 +590,7 @@ int main(int argc, char *argv[]) @@ -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()));

9
src/util.cpp

@ -518,19 +518,20 @@ void ClearDatadirCache() @@ -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

4
src/util.h

@ -102,12 +102,12 @@ bool TryCreateDirectory(const boost::filesystem::path& p); @@ -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