Skip to content

Commit a7e5cbb

Browse files
committed
Merge #8856: Globals: Decouple GetConfigFile and ReadConfigFile from global mapArgs
3450c18 Globals: Decouple GetConfigFile and ReadConfigFile from global mapArgs (Jorge Timón)
2 parents 76f3c02 + 3450c18 commit a7e5cbb

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

src/bitcoin-cli.cpp

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

214214
}
215215
} else {

src/bitcoind.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ bool AppInit(int argc, char* argv[])
104104
}
105105
try
106106
{
107-
ReadConfigFile(mapArgs, mapMultiArgs);
107+
ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME), mapArgs, mapMultiArgs);
108108
} catch (const std::exception& e) {
109109
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
110110
return false;

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
10641064
LogPrintf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()));
10651065
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
10661066
LogPrintf("Using data directory %s\n", strDataDir);
1067-
LogPrintf("Using config file %s\n", GetConfigFile().string());
1067+
LogPrintf("Using config file %s\n", GetConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME)).string());
10681068
LogPrintf("Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD);
10691069

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

src/qt/bitcoin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ int main(int argc, char *argv[])
590590
return 1;
591591
}
592592
try {
593-
ReadConfigFile(mapArgs, mapMultiArgs);
593+
ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME), mapArgs, mapMultiArgs);
594594
} catch (const std::exception& e) {
595595
QMessageBox::critical(0, QObject::tr(PACKAGE_NAME),
596596
QObject::tr("Error: Cannot parse configuration file: %1. Only use key=value syntax.").arg(e.what()));

src/util.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,19 +518,20 @@ void ClearDatadirCache()
518518
pathCachedNetSpecific = boost::filesystem::path();
519519
}
520520

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

527527
return pathConfigFile;
528528
}
529529

530-
void ReadConfigFile(map<string, string>& mapSettingsRet,
530+
void ReadConfigFile(const std::string& confPath,
531+
map<string, string>& mapSettingsRet,
531532
map<string, vector<string> >& mapMultiSettingsRet)
532533
{
533-
boost::filesystem::ifstream streamConfig(GetConfigFile());
534+
boost::filesystem::ifstream streamConfig(GetConfigFile(confPath));
534535
if (!streamConfig.good())
535536
return; // No bitcoin.conf file is OK
536537

src/util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ bool TryCreateDirectory(const boost::filesystem::path& p);
102102
boost::filesystem::path GetDefaultDataDir();
103103
const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);
104104
void ClearDatadirCache();
105-
boost::filesystem::path GetConfigFile();
105+
boost::filesystem::path GetConfigFile(const std::string& confPath);
106106
#ifndef WIN32
107107
boost::filesystem::path GetPidFile();
108108
void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
109109
#endif
110-
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
110+
void ReadConfigFile(const std::string& confPath, std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
111111
#ifdef WIN32
112112
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
113113
#endif

0 commit comments

Comments
 (0)