@@ -708,24 +708,24 @@ void InitParameterInteraction()
708
708
{
709
709
// when specifying an explicit binding address, you want to listen on it
710
710
// even when -connect or -proxy is specified
711
- if (mapArgs. count (" -bind" )) {
711
+ if (IsArgSet (" -bind" )) {
712
712
if (SoftSetBoolArg (" -listen" , true ))
713
713
LogPrintf (" %s: parameter interaction: -bind set -> setting -listen=1\n " , __func__);
714
714
}
715
- if (mapArgs. count (" -whitebind" )) {
715
+ if (IsArgSet (" -whitebind" )) {
716
716
if (SoftSetBoolArg (" -listen" , true ))
717
717
LogPrintf (" %s: parameter interaction: -whitebind set -> setting -listen=1\n " , __func__);
718
718
}
719
719
720
- if (mapArgs .count (" -connect" ) && mapMultiArgs[ " -connect" ] .size () > 0 ) {
720
+ if (mapMultiArgs .count (" -connect" ) && mapMultiArgs. at ( " -connect" ) .size () > 0 ) {
721
721
// when only connecting to trusted nodes, do not seed via DNS, or listen by default
722
722
if (SoftSetBoolArg (" -dnsseed" , false ))
723
723
LogPrintf (" %s: parameter interaction: -connect set -> setting -dnsseed=0\n " , __func__);
724
724
if (SoftSetBoolArg (" -listen" , false ))
725
725
LogPrintf (" %s: parameter interaction: -connect set -> setting -listen=0\n " , __func__);
726
726
}
727
727
728
- if (mapArgs. count (" -proxy" )) {
728
+ if (IsArgSet (" -proxy" )) {
729
729
// to protect privacy, do not listen by default if a default proxy server is specified
730
730
if (SoftSetBoolArg (" -listen" , false ))
731
731
LogPrintf (" %s: parameter interaction: -proxy set -> setting -listen=0\n " , __func__);
@@ -748,7 +748,7 @@ void InitParameterInteraction()
748
748
LogPrintf (" %s: parameter interaction: -listen=0 -> setting -listenonion=0\n " , __func__);
749
749
}
750
750
751
- if (mapArgs. count (" -externalip" )) {
751
+ if (IsArgSet (" -externalip" )) {
752
752
// if an explicit public IP is specified, do not try to find others
753
753
if (SoftSetBoolArg (" -discover" , false ))
754
754
LogPrintf (" %s: parameter interaction: -externalip set -> setting -discover=0\n " , __func__);
@@ -880,17 +880,19 @@ bool AppInitParameterInteraction()
880
880
881
881
// ********************************************************* Step 3: parameter-to-internal-flags
882
882
883
- fDebug = ! mapMultiArgs[ " -debug" ]. empty ( );
883
+ fDebug = mapMultiArgs. count ( " -debug" );
884
884
// Special-case: if -debug=0/-nodebug is set, turn off debugging messages
885
- const vector<string>& categories = mapMultiArgs[" -debug" ];
886
- if (GetBoolArg (" -nodebug" , false ) || find (categories.begin (), categories.end (), string (" 0" )) != categories.end ())
887
- fDebug = false ;
885
+ if (fDebug ) {
886
+ const vector<string>& categories = mapMultiArgs.at (" -debug" );
887
+ if (GetBoolArg (" -nodebug" , false ) || find (categories.begin (), categories.end (), string (" 0" )) != categories.end ())
888
+ fDebug = false ;
889
+ }
888
890
889
891
// Check for -debugnet
890
892
if (GetBoolArg (" -debugnet" , false ))
891
893
InitWarning (_ (" Unsupported argument -debugnet ignored, use -debug=net." ));
892
894
// Check for -socks - as this is a privacy risk to continue, exit here
893
- if (mapArgs. count (" -socks" ))
895
+ if (IsArgSet (" -socks" ))
894
896
return InitError (_ (" Unsupported argument -socks found. Setting SOCKS version isn't possible anymore, only SOCKS5 proxies are supported." ));
895
897
// Check for -tor - as this is a privacy risk to continue, exit here
896
898
if (GetBoolArg (" -tor" , false ))
@@ -902,7 +904,7 @@ bool AppInitParameterInteraction()
902
904
if (GetBoolArg (" -whitelistalwaysrelay" , false ))
903
905
InitWarning (_ (" Unsupported argument -whitelistalwaysrelay ignored, use -whitelistrelay and/or -whitelistforcerelay." ));
904
906
905
- if (mapArgs. count (" -blockminsize" ))
907
+ if (IsArgSet (" -blockminsize" ))
906
908
InitWarning (" Unsupported argument -blockminsize ignored." );
907
909
908
910
// Checkmempool and checkblockindex default to true in regtest mode
@@ -957,11 +959,11 @@ bool AppInitParameterInteraction()
957
959
// a transaction spammer can cheaply fill blocks using
958
960
// 1-satoshi-fee transactions. It should be set above the real
959
961
// cost to you of processing a transaction.
960
- if (mapArgs. count (" -minrelaytxfee" ))
962
+ if (IsArgSet (" -minrelaytxfee" ))
961
963
{
962
964
CAmount n = 0 ;
963
- if (!ParseMoney (mapArgs[ " -minrelaytxfee" ] , n) || 0 == n)
964
- return InitError (AmountErrMsg (" minrelaytxfee" , mapArgs[ " -minrelaytxfee" ] ));
965
+ if (!ParseMoney (GetArg ( " -minrelaytxfee" , " " ) , n) || 0 == n)
966
+ return InitError (AmountErrMsg (" minrelaytxfee" , GetArg ( " -minrelaytxfee" , " " ) ));
965
967
// High fee check is done afterward in CWallet::ParameterInteraction()
966
968
::minRelayTxFee = CFeeRate (n);
967
969
}
@@ -995,20 +997,20 @@ bool AppInitParameterInteraction()
995
997
nMaxTipAge = GetArg (" -maxtipage" , DEFAULT_MAX_TIP_AGE);
996
998
997
999
fEnableReplacement = GetBoolArg (" -mempoolreplacement" , DEFAULT_ENABLE_REPLACEMENT);
998
- if ((!fEnableReplacement ) && mapArgs. count (" -mempoolreplacement" )) {
1000
+ if ((!fEnableReplacement ) && IsArgSet (" -mempoolreplacement" )) {
999
1001
// Minimal effort at forwards compatibility
1000
1002
std::string strReplacementModeList = GetArg (" -mempoolreplacement" , " " ); // default is impossible
1001
1003
std::vector<std::string> vstrReplacementModes;
1002
1004
boost::split (vstrReplacementModes, strReplacementModeList, boost::is_any_of (" ," ));
1003
1005
fEnableReplacement = (std::find (vstrReplacementModes.begin (), vstrReplacementModes.end (), " fee" ) != vstrReplacementModes.end ());
1004
1006
}
1005
1007
1006
- if (! mapMultiArgs[ " -bip9params" ]. empty ( )) {
1008
+ if (mapMultiArgs. count ( " -bip9params" )) {
1007
1009
// Allow overriding BIP9 parameters for testing
1008
1010
if (!chainparams.MineBlocksOnDemand ()) {
1009
1011
return InitError (" BIP9 parameters may only be overridden on regtest." );
1010
1012
}
1011
- const vector<string>& deployments = mapMultiArgs[ " -bip9params" ] ;
1013
+ const vector<string>& deployments = mapMultiArgs. at ( " -bip9params" ) ;
1012
1014
for (auto i : deployments) {
1013
1015
std::vector<std::string> vDeploymentParams;
1014
1016
boost::split (vDeploymentParams, i, boost::is_any_of (" :" ));
@@ -1154,21 +1156,23 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1154
1156
1155
1157
// sanitize comments per BIP-0014, format user agent and check total size
1156
1158
std::vector<string> uacomments;
1157
- BOOST_FOREACH (string cmt, mapMultiArgs[" -uacomment" ])
1158
- {
1159
- if (cmt != SanitizeString (cmt, SAFE_CHARS_UA_COMMENT))
1160
- return InitError (strprintf (_ (" User Agent comment (%s) contains unsafe characters." ), cmt));
1161
- uacomments.push_back (SanitizeString (cmt, SAFE_CHARS_UA_COMMENT));
1159
+ if (mapMultiArgs.count (" -uacomment" )) {
1160
+ BOOST_FOREACH (string cmt, mapMultiArgs.at (" -uacomment" ))
1161
+ {
1162
+ if (cmt != SanitizeString (cmt, SAFE_CHARS_UA_COMMENT))
1163
+ return InitError (strprintf (_ (" User Agent comment (%s) contains unsafe characters." ), cmt));
1164
+ uacomments.push_back (cmt);
1165
+ }
1162
1166
}
1163
1167
strSubVersion = FormatSubVersion (CLIENT_NAME, CLIENT_VERSION, uacomments);
1164
1168
if (strSubVersion.size () > MAX_SUBVERSION_LENGTH) {
1165
1169
return InitError (strprintf (_ (" Total length of network version string (%i) exceeds maximum length (%i). Reduce the number or size of uacomments." ),
1166
1170
strSubVersion.size (), MAX_SUBVERSION_LENGTH));
1167
1171
}
1168
1172
1169
- if (mapArgs .count (" -onlynet" )) {
1173
+ if (mapMultiArgs .count (" -onlynet" )) {
1170
1174
std::set<enum Network> nets;
1171
- BOOST_FOREACH (const std::string& snet, mapMultiArgs[ " -onlynet" ] ) {
1175
+ BOOST_FOREACH (const std::string& snet, mapMultiArgs. at ( " -onlynet" ) ) {
1172
1176
enum Network net = ParseNetwork (snet);
1173
1177
if (net == NET_UNROUTABLE)
1174
1178
return InitError (strprintf (_ (" Unknown network specified in -onlynet: '%s'" ), snet));
@@ -1181,8 +1185,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1181
1185
}
1182
1186
}
1183
1187
1184
- if (mapArgs .count (" -whitelist" )) {
1185
- BOOST_FOREACH (const std::string& net, mapMultiArgs[ " -whitelist" ] ) {
1188
+ if (mapMultiArgs .count (" -whitelist" )) {
1189
+ BOOST_FOREACH (const std::string& net, mapMultiArgs. at ( " -whitelist" ) ) {
1186
1190
CSubNet subnet;
1187
1191
LookupSubNet (net.c_str (), subnet);
1188
1192
if (!subnet.IsValid ())
@@ -1234,14 +1238,16 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1234
1238
1235
1239
if (fListen ) {
1236
1240
bool fBound = false ;
1237
- if (mapArgs .count (" -bind" ) || mapArgs. count ( " -whitebind " )) {
1238
- BOOST_FOREACH (const std::string& strBind, mapMultiArgs[ " -bind" ] ) {
1241
+ if (mapMultiArgs .count (" -bind" )) {
1242
+ BOOST_FOREACH (const std::string& strBind, mapMultiArgs. at ( " -bind" ) ) {
1239
1243
CService addrBind;
1240
1244
if (!Lookup (strBind.c_str (), addrBind, GetListenPort (), false ))
1241
1245
return InitError (ResolveErrMsg (" bind" , strBind));
1242
1246
fBound |= Bind (connman, addrBind, (BF_EXPLICIT | BF_REPORT_ERROR));
1243
1247
}
1244
- BOOST_FOREACH (const std::string& strBind, mapMultiArgs[" -whitebind" ]) {
1248
+ }
1249
+ if (mapMultiArgs.count (" -whitebind" )) {
1250
+ BOOST_FOREACH (const std::string& strBind, mapMultiArgs.at (" -whitebind" )) {
1245
1251
CService addrBind;
1246
1252
if (!Lookup (strBind.c_str (), addrBind, 0 , false ))
1247
1253
return InitError (ResolveErrMsg (" whitebind" , strBind));
@@ -1250,7 +1256,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1250
1256
fBound |= Bind (connman, addrBind, (BF_EXPLICIT | BF_REPORT_ERROR | BF_WHITELIST));
1251
1257
}
1252
1258
}
1253
- else {
1259
+ if (!mapMultiArgs. count ( " -bind " ) && !mapMultiArgs. count ( " -whitebind " )) {
1254
1260
struct in_addr inaddr_any;
1255
1261
inaddr_any.s_addr = INADDR_ANY;
1256
1262
fBound |= Bind (connman, CService (in6addr_any, GetListenPort ()), BF_NONE);
@@ -1260,8 +1266,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1260
1266
return InitError (_ (" Failed to listen on any port. Use -listen=0 if you want this." ));
1261
1267
}
1262
1268
1263
- if (mapArgs .count (" -externalip" )) {
1264
- BOOST_FOREACH (const std::string& strAddr, mapMultiArgs[ " -externalip" ] ) {
1269
+ if (mapMultiArgs .count (" -externalip" )) {
1270
+ BOOST_FOREACH (const std::string& strAddr, mapMultiArgs. at ( " -externalip" ) ) {
1265
1271
CService addrLocal;
1266
1272
if (Lookup (strAddr.c_str (), addrLocal, GetListenPort (), fNameLookup ) && addrLocal.IsValid ())
1267
1273
AddLocal (addrLocal, LOCAL_MANUAL);
@@ -1270,11 +1276,13 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1270
1276
}
1271
1277
}
1272
1278
1273
- BOOST_FOREACH (const std::string& strDest, mapMultiArgs[" -seednode" ])
1274
- connman.AddOneShot (strDest);
1279
+ if (mapMultiArgs.count (" -seednode" )) {
1280
+ BOOST_FOREACH (const std::string& strDest, mapMultiArgs.at (" -seednode" ))
1281
+ connman.AddOneShot (strDest);
1282
+ }
1275
1283
1276
1284
#if ENABLE_ZMQ
1277
- pzmqNotificationInterface = CZMQNotificationInterface::CreateWithArguments (mapArgs );
1285
+ pzmqNotificationInterface = CZMQNotificationInterface::Create ( );
1278
1286
1279
1287
if (pzmqNotificationInterface) {
1280
1288
RegisterValidationInterface (pzmqNotificationInterface);
@@ -1283,7 +1291,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1283
1291
uint64_t nMaxOutboundLimit = 0 ; // unlimited unless -maxuploadtarget is set
1284
1292
uint64_t nMaxOutboundTimeframe = MAX_UPLOAD_TIMEFRAME;
1285
1293
1286
- if (mapArgs. count (" -maxuploadtarget" )) {
1294
+ if (IsArgSet (" -maxuploadtarget" )) {
1287
1295
nMaxOutboundLimit = GetArg (" -maxuploadtarget" , DEFAULT_MAX_UPLOAD_TARGET)*1024 *1024 ;
1288
1296
}
1289
1297
@@ -1515,13 +1523,13 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1515
1523
fHaveGenesis = true ;
1516
1524
}
1517
1525
1518
- if (mapArgs. count (" -blocknotify" ))
1526
+ if (IsArgSet (" -blocknotify" ))
1519
1527
uiInterface.NotifyBlockTip .connect (BlockNotifyCallback);
1520
1528
1521
1529
std::vector<boost::filesystem::path> vImportFiles;
1522
- if (mapArgs .count (" -loadblock" ))
1530
+ if (mapMultiArgs .count (" -loadblock" ))
1523
1531
{
1524
- BOOST_FOREACH (const std::string& strFile, mapMultiArgs[ " -loadblock" ] )
1532
+ BOOST_FOREACH (const std::string& strFile, mapMultiArgs. at ( " -loadblock" ) )
1525
1533
vImportFiles.push_back (strFile);
1526
1534
}
1527
1535
0 commit comments