Skip to content

Commit 4cd373a

Browse files
committed
Un-expose mapArgs from utils.h
1 parent 71fde55 commit 4cd373a

14 files changed

+30
-24
lines changed

src/bitcoin-cli.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static int AppInitRPC(int argc, char* argv[])
9595
return EXIT_SUCCESS;
9696
}
9797
if (!boost::filesystem::is_directory(GetDataDir(false))) {
98-
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str());
98+
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", GetArg("-datadir", "").c_str());
9999
return EXIT_FAILURE;
100100
}
101101
try {
@@ -211,7 +211,7 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
211211

212212
// Get credentials
213213
std::string strRPCUserColonPass;
214-
if (mapArgs["-rpcpassword"] == "") {
214+
if (GetArg("-rpcpassword", "") == "") {
215215
// Try fall back to cookie-based authentication if no password is provided
216216
if (!GetAuthCookie(&strRPCUserColonPass)) {
217217
throw std::runtime_error(strprintf(
@@ -220,7 +220,7 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
220220

221221
}
222222
} else {
223-
strRPCUserColonPass = mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"];
223+
strRPCUserColonPass = GetArg("-rpcuser", "") + ":" + GetArg("-rpcpassword", "");
224224
}
225225

226226
struct evkeyvalq *output_headers = evhttp_request_get_output_headers(req);

src/bitcoind.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ bool AppInit(int argc, char* argv[])
9999
{
100100
if (!boost::filesystem::is_directory(GetDataDir(false)))
101101
{
102-
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str());
102+
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", GetArg("-datadir", "").c_str());
103103
return false;
104104
}
105105
try

src/httprpc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static bool HTTPReq_JSONRPC(HTTPRequest* req, const std::string &)
215215

216216
static bool InitRPCAuthentication()
217217
{
218-
if (mapArgs["-rpcpassword"] == "")
218+
if (GetArg("-rpcpassword", "") == "")
219219
{
220220
LogPrintf("No rpcpassword set - using random cookie authentication\n");
221221
if (!GenerateAuthCookie(&strRPCUserColonPass)) {
@@ -226,7 +226,7 @@ static bool InitRPCAuthentication()
226226
}
227227
} else {
228228
LogPrintf("Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcuser for rpcauth auth generation.\n");
229-
strRPCUserColonPass = mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"];
229+
strRPCUserColonPass = GetArg("-rpcuser", "") + ":" + GetArg("-rpcpassword", "");
230230
}
231231
return true;
232232
}

src/init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,8 +962,8 @@ bool AppInitParameterInteraction()
962962
if (IsArgSet("-minrelaytxfee"))
963963
{
964964
CAmount n = 0;
965-
if (!ParseMoney(mapArgs["-minrelaytxfee"], n) || 0 == n)
966-
return InitError(AmountErrMsg("minrelaytxfee", mapArgs["-minrelaytxfee"]));
965+
if (!ParseMoney(GetArg("-minrelaytxfee", ""), n) || 0 == n)
966+
return InitError(AmountErrMsg("minrelaytxfee", GetArg("-minrelaytxfee", "")));
967967
// High fee check is done afterward in CWallet::ParameterInteraction()
968968
::minRelayTxFee = CFeeRate(n);
969969
}

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
10601060
unsigned int nMaxSendBufferSize = connman.GetSendBufferSize();
10611061

10621062
LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id);
1063-
if (IsArgSet("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
1063+
if (IsArgSet("-dropmessagestest") && GetRand(GetArg("-dropmessagestest", 0)) == 0)
10641064
{
10651065
LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n");
10661066
return true;

src/qt/bitcoin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ int main(int argc, char *argv[])
604604
if (!boost::filesystem::is_directory(GetDataDir(false)))
605605
{
606606
QMessageBox::critical(0, QObject::tr(PACKAGE_NAME),
607-
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(mapArgs["-datadir"])));
607+
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(GetArg("-datadir", ""))));
608608
return EXIT_FAILURE;
609609
}
610610
try {

src/qt/optionsmodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ OptionsModel::OptionsModel(QObject *parent, bool resetSettings) :
3636

3737
void OptionsModel::addOverriddenOption(const std::string &option)
3838
{
39-
strOverriddenByCommandLine += QString::fromStdString(option) + "=" + QString::fromStdString(mapArgs[option]) + " ";
39+
strOverriddenByCommandLine += QString::fromStdString(option) + "=" + QString::fromStdString(GetArg(option, "")) + " ";
4040
}
4141

4242
// Writes all missing QSettings with their default values
@@ -464,4 +464,4 @@ void OptionsModel::checkAndMigrate()
464464

465465
settings.setValue(strSettingsVersionKey, CLIENT_VERSION);
466466
}
467-
}
467+
}

src/qt/test/rpcnestedtests.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include <boost/filesystem.hpp>
2121

22+
extern std::map<std::string, std::string> mapArgs;
23+
2224
static UniValue rpcNestedTest_rpc(const JSONRPCRequest& request)
2325
{
2426
if (request.fHelp) {

src/test/DoS_tests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct COrphanTx {
3232
int64_t nTimeExpire;
3333
};
3434
extern std::map<uint256, COrphanTx> mapOrphanTransactions;
35+
extern std::map<std::string, std::string> mapArgs;
3536

3637
CService ip(uint32_t i)
3738
{

src/test/test_bitcoin.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
std::unique_ptr<CConnman> g_connman;
3434
FastRandomContext insecure_rand_ctx(true);
3535

36+
extern std::map<std::string, std::string> mapArgs;
37+
3638
extern bool fPrintToConsole;
3739
extern void noui_connect();
3840

0 commit comments

Comments
 (0)