Skip to content

Commit b3cbd55

Browse files
committed
scripted-diff: Util: Encapsulate mapMultiArgs behind gArgs
-BEGIN VERIFY SCRIPT- sed -i 's/mapMultiArgs.count(/gArgs.IsArgSet(/g' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ; sed -i 's/mapMultiArgs.at("/gArgs.GetArgs("/g' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ; -END VERIFY SCRIPT-
1 parent f2957ce commit b3cbd55

File tree

4 files changed

+37
-37
lines changed

4 files changed

+37
-37
lines changed

src/httprpc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ static bool multiUserAuthorized(std::string strUserPass)
9393
std::string strUser = strUserPass.substr(0, strUserPass.find(":"));
9494
std::string strPass = strUserPass.substr(strUserPass.find(":") + 1);
9595

96-
if (mapMultiArgs.count("-rpcauth") > 0) {
96+
if (gArgs.IsArgSet("-rpcauth") > 0) {
9797
//Search for multi-user login/pass "rpcauth" from config
98-
BOOST_FOREACH(std::string strRPCAuth, mapMultiArgs.at("-rpcauth"))
98+
BOOST_FOREACH(std::string strRPCAuth, gArgs.GetArgs("-rpcauth"))
9999
{
100100
std::vector<std::string> vFields;
101101
boost::split(vFields, strRPCAuth, boost::is_any_of(":$"));

src/httpserver.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ static bool InitHTTPAllowList()
196196
LookupHost("::1", localv6, false);
197197
rpc_allow_subnets.push_back(CSubNet(localv4, 8)); // always allow IPv4 local subnet
198198
rpc_allow_subnets.push_back(CSubNet(localv6)); // always allow IPv6 localhost
199-
if (mapMultiArgs.count("-rpcallowip")) {
200-
const std::vector<std::string>& vAllow = mapMultiArgs.at("-rpcallowip");
199+
if (gArgs.IsArgSet("-rpcallowip")) {
200+
const std::vector<std::string>& vAllow = gArgs.GetArgs("-rpcallowip");
201201
for (std::string strAllow : vAllow) {
202202
CSubNet subnet;
203203
LookupSubNet(strAllow.c_str(), subnet);
@@ -321,8 +321,8 @@ static bool HTTPBindAddresses(struct evhttp* http)
321321
if (IsArgSet("-rpcbind")) {
322322
LogPrintf("WARNING: option -rpcbind was ignored because -rpcallowip was not specified, refusing to allow everyone to connect\n");
323323
}
324-
} else if (mapMultiArgs.count("-rpcbind")) { // Specific bind address
325-
const std::vector<std::string>& vbind = mapMultiArgs.at("-rpcbind");
324+
} else if (gArgs.IsArgSet("-rpcbind")) { // Specific bind address
325+
const std::vector<std::string>& vbind = gArgs.GetArgs("-rpcbind");
326326
for (std::vector<std::string>::const_iterator i = vbind.begin(); i != vbind.end(); ++i) {
327327
int port = defaultPort;
328328
std::string host;

src/init.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ void InitParameterInteraction()
741741
LogPrintf("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__);
742742
}
743743

744-
if (mapMultiArgs.count("-connect") && mapMultiArgs.at("-connect").size() > 0) {
744+
if (gArgs.IsArgSet("-connect") && gArgs.GetArgs("-connect").size() > 0) {
745745
// when only connecting to trusted nodes, do not seed via DNS, or listen by default
746746
if (SoftSetBoolArg("-dnsseed", false))
747747
LogPrintf("%s: parameter interaction: -connect set -> setting -dnsseed=0\n", __func__);
@@ -895,8 +895,8 @@ bool AppInitParameterInteraction()
895895

896896
// Make sure enough file descriptors are available
897897
int nBind = std::max(
898-
(mapMultiArgs.count("-bind") ? mapMultiArgs.at("-bind").size() : 0) +
899-
(mapMultiArgs.count("-whitebind") ? mapMultiArgs.at("-whitebind").size() : 0), size_t(1));
898+
(gArgs.IsArgSet("-bind") ? gArgs.GetArgs("-bind").size() : 0) +
899+
(gArgs.IsArgSet("-whitebind") ? gArgs.GetArgs("-whitebind").size() : 0), size_t(1));
900900
nUserMaxConnections = GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS);
901901
nMaxConnections = std::max(nUserMaxConnections, 0);
902902

@@ -911,9 +911,9 @@ bool AppInitParameterInteraction()
911911
InitWarning(strprintf(_("Reducing -maxconnections from %d to %d, because of system limitations."), nUserMaxConnections, nMaxConnections));
912912

913913
// ********************************************************* Step 3: parameter-to-internal-flags
914-
if (mapMultiArgs.count("-debug") > 0) {
914+
if (gArgs.IsArgSet("-debug") > 0) {
915915
// Special-case: if -debug=0/-nodebug is set, turn off debugging messages
916-
const std::vector<std::string>& categories = mapMultiArgs.at("-debug");
916+
const std::vector<std::string>& categories = gArgs.GetArgs("-debug");
917917

918918
if (find(categories.begin(), categories.end(), std::string("0")) == categories.end()) {
919919
for (const auto& cat : categories) {
@@ -928,8 +928,8 @@ bool AppInitParameterInteraction()
928928
}
929929

930930
// Now remove the logging categories which were explicitly excluded
931-
if (mapMultiArgs.count("-debugexclude") > 0) {
932-
const std::vector<std::string>& excludedCategories = mapMultiArgs.at("-debugexclude");
931+
if (gArgs.IsArgSet("-debugexclude") > 0) {
932+
const std::vector<std::string>& excludedCategories = gArgs.GetArgs("-debugexclude");
933933
for (const auto& cat : excludedCategories) {
934934
uint32_t flag = 0;
935935
if (!GetLogCategory(&flag, &cat)) {
@@ -1100,12 +1100,12 @@ bool AppInitParameterInteraction()
11001100
fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "fee") != vstrReplacementModes.end());
11011101
}
11021102

1103-
if (mapMultiArgs.count("-bip9params")) {
1103+
if (gArgs.IsArgSet("-bip9params")) {
11041104
// Allow overriding BIP9 parameters for testing
11051105
if (!chainparams.MineBlocksOnDemand()) {
11061106
return InitError("BIP9 parameters may only be overridden on regtest.");
11071107
}
1108-
const std::vector<std::string>& deployments = mapMultiArgs.at("-bip9params");
1108+
const std::vector<std::string>& deployments = gArgs.GetArgs("-bip9params");
11091109
for (auto i : deployments) {
11101110
std::vector<std::string> vDeploymentParams;
11111111
boost::split(vDeploymentParams, i, boost::is_any_of(":"));
@@ -1254,8 +1254,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
12541254

12551255
// sanitize comments per BIP-0014, format user agent and check total size
12561256
std::vector<std::string> uacomments;
1257-
if (mapMultiArgs.count("-uacomment")) {
1258-
BOOST_FOREACH(std::string cmt, mapMultiArgs.at("-uacomment"))
1257+
if (gArgs.IsArgSet("-uacomment")) {
1258+
BOOST_FOREACH(std::string cmt, gArgs.GetArgs("-uacomment"))
12591259
{
12601260
if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT))
12611261
return InitError(strprintf(_("User Agent comment (%s) contains unsafe characters."), cmt));
@@ -1268,9 +1268,9 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
12681268
strSubVersion.size(), MAX_SUBVERSION_LENGTH));
12691269
}
12701270

1271-
if (mapMultiArgs.count("-onlynet")) {
1271+
if (gArgs.IsArgSet("-onlynet")) {
12721272
std::set<enum Network> nets;
1273-
BOOST_FOREACH(const std::string& snet, mapMultiArgs.at("-onlynet")) {
1273+
BOOST_FOREACH(const std::string& snet, gArgs.GetArgs("-onlynet")) {
12741274
enum Network net = ParseNetwork(snet);
12751275
if (net == NET_UNROUTABLE)
12761276
return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet));
@@ -1283,8 +1283,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
12831283
}
12841284
}
12851285

1286-
if (mapMultiArgs.count("-whitelist")) {
1287-
BOOST_FOREACH(const std::string& net, mapMultiArgs.at("-whitelist")) {
1286+
if (gArgs.IsArgSet("-whitelist")) {
1287+
BOOST_FOREACH(const std::string& net, gArgs.GetArgs("-whitelist")) {
12881288
CSubNet subnet;
12891289
LookupSubNet(net.c_str(), subnet);
12901290
if (!subnet.IsValid())
@@ -1345,16 +1345,16 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
13451345

13461346
if (fListen) {
13471347
bool fBound = false;
1348-
if (mapMultiArgs.count("-bind")) {
1349-
BOOST_FOREACH(const std::string& strBind, mapMultiArgs.at("-bind")) {
1348+
if (gArgs.IsArgSet("-bind")) {
1349+
BOOST_FOREACH(const std::string& strBind, gArgs.GetArgs("-bind")) {
13501350
CService addrBind;
13511351
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false))
13521352
return InitError(ResolveErrMsg("bind", strBind));
13531353
fBound |= Bind(connman, addrBind, (BF_EXPLICIT | BF_REPORT_ERROR));
13541354
}
13551355
}
1356-
if (mapMultiArgs.count("-whitebind")) {
1357-
BOOST_FOREACH(const std::string& strBind, mapMultiArgs.at("-whitebind")) {
1356+
if (gArgs.IsArgSet("-whitebind")) {
1357+
BOOST_FOREACH(const std::string& strBind, gArgs.GetArgs("-whitebind")) {
13581358
CService addrBind;
13591359
if (!Lookup(strBind.c_str(), addrBind, 0, false))
13601360
return InitError(ResolveErrMsg("whitebind", strBind));
@@ -1363,7 +1363,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
13631363
fBound |= Bind(connman, addrBind, (BF_EXPLICIT | BF_REPORT_ERROR | BF_WHITELIST));
13641364
}
13651365
}
1366-
if (!mapMultiArgs.count("-bind") && !mapMultiArgs.count("-whitebind")) {
1366+
if (!gArgs.IsArgSet("-bind") && !gArgs.IsArgSet("-whitebind")) {
13671367
struct in_addr inaddr_any;
13681368
inaddr_any.s_addr = INADDR_ANY;
13691369
fBound |= Bind(connman, CService(in6addr_any, GetListenPort()), BF_NONE);
@@ -1373,8 +1373,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
13731373
return InitError(_("Failed to listen on any port. Use -listen=0 if you want this."));
13741374
}
13751375

1376-
if (mapMultiArgs.count("-externalip")) {
1377-
BOOST_FOREACH(const std::string& strAddr, mapMultiArgs.at("-externalip")) {
1376+
if (gArgs.IsArgSet("-externalip")) {
1377+
BOOST_FOREACH(const std::string& strAddr, gArgs.GetArgs("-externalip")) {
13781378
CService addrLocal;
13791379
if (Lookup(strAddr.c_str(), addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid())
13801380
AddLocal(addrLocal, LOCAL_MANUAL);
@@ -1383,8 +1383,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
13831383
}
13841384
}
13851385

1386-
if (mapMultiArgs.count("-seednode")) {
1387-
BOOST_FOREACH(const std::string& strDest, mapMultiArgs.at("-seednode"))
1386+
if (gArgs.IsArgSet("-seednode")) {
1387+
BOOST_FOREACH(const std::string& strDest, gArgs.GetArgs("-seednode"))
13881388
connman.AddOneShot(strDest);
13891389
}
13901390

@@ -1610,9 +1610,9 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
16101610
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback);
16111611

16121612
std::vector<fs::path> vImportFiles;
1613-
if (mapMultiArgs.count("-loadblock"))
1613+
if (gArgs.IsArgSet("-loadblock"))
16141614
{
1615-
BOOST_FOREACH(const std::string& strFile, mapMultiArgs.at("-loadblock"))
1615+
BOOST_FOREACH(const std::string& strFile, gArgs.GetArgs("-loadblock"))
16161616
vImportFiles.push_back(strFile);
16171617
}
16181618

src/net.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,12 +1670,12 @@ void CConnman::ProcessOneShot()
16701670
void CConnman::ThreadOpenConnections()
16711671
{
16721672
// Connect to specific addresses
1673-
if (mapMultiArgs.count("-connect") && mapMultiArgs.at("-connect").size() > 0)
1673+
if (gArgs.IsArgSet("-connect") && gArgs.GetArgs("-connect").size() > 0)
16741674
{
16751675
for (int64_t nLoop = 0;; nLoop++)
16761676
{
16771677
ProcessOneShot();
1678-
BOOST_FOREACH(const std::string& strAddr, mapMultiArgs.at("-connect"))
1678+
BOOST_FOREACH(const std::string& strAddr, gArgs.GetArgs("-connect"))
16791679
{
16801680
CAddress addr(CService(), NODE_NONE);
16811681
OpenNetworkConnection(addr, false, NULL, strAddr.c_str());
@@ -1877,8 +1877,8 @@ void CConnman::ThreadOpenAddedConnections()
18771877
{
18781878
{
18791879
LOCK(cs_vAddedNodes);
1880-
if (mapMultiArgs.count("-addnode"))
1881-
vAddedNodes = mapMultiArgs.at("-addnode");
1880+
if (gArgs.IsArgSet("-addnode"))
1881+
vAddedNodes = gArgs.GetArgs("-addnode");
18821882
}
18831883

18841884
while (true)
@@ -2289,7 +2289,7 @@ bool CConnman::Start(CScheduler& scheduler, std::string& strNodeError, Options c
22892289
threadOpenAddedConnections = std::thread(&TraceThread<std::function<void()> >, "addcon", std::function<void()>(std::bind(&CConnman::ThreadOpenAddedConnections, this)));
22902290

22912291
// Initiate outbound connections unless connect=0
2292-
if (!mapMultiArgs.count("-connect") || mapMultiArgs.at("-connect").size() != 1 || mapMultiArgs.at("-connect")[0] != "0")
2292+
if (!gArgs.IsArgSet("-connect") || gArgs.GetArgs("-connect").size() != 1 || gArgs.GetArgs("-connect")[0] != "0")
22932293
threadOpenConnections = std::thread(&TraceThread<std::function<void()> >, "opencon", std::function<void()>(std::bind(&CConnman::ThreadOpenConnections, this)));
22942294

22952295
// Process messages

0 commit comments

Comments
 (0)