@@ -880,9 +880,7 @@ bool AppInitParameterInteraction()
880
880
}
881
881
882
882
// -bind and -whitebind can't be set when not listening
883
- size_t nUserBind =
884
- (gArgs .IsArgSet (" -bind" ) ? gArgs .GetArgs (" -bind" ).size () : 0 ) +
885
- (gArgs .IsArgSet (" -whitebind" ) ? gArgs .GetArgs (" -whitebind" ).size () : 0 );
883
+ size_t nUserBind = gArgs .GetArgs (" -bind" ).size () + gArgs .GetArgs (" -whitebind" ).size ();
886
884
if (nUserBind != 0 && !gArgs .GetBoolArg (" -listen" , DEFAULT_LISTEN)) {
887
885
return InitError (" Cannot set -bind or -whitebind together with -listen=0" );
888
886
}
@@ -920,15 +918,13 @@ bool AppInitParameterInteraction()
920
918
}
921
919
922
920
// Now remove the logging categories which were explicitly excluded
923
- if (gArgs .IsArgSet (" -debugexclude" )) {
924
- for (const std::string& cat : gArgs .GetArgs (" -debugexclude" )) {
925
- uint32_t flag = 0 ;
926
- if (!GetLogCategory (&flag, &cat)) {
927
- InitWarning (strprintf (_ (" Unsupported logging category %s=%s." ), " -debugexclude" , cat));
928
- continue ;
929
- }
930
- logCategories &= ~flag;
921
+ for (const std::string& cat : gArgs .GetArgs (" -debugexclude" )) {
922
+ uint32_t flag = 0 ;
923
+ if (!GetLogCategory (&flag, &cat)) {
924
+ InitWarning (strprintf (_ (" Unsupported logging category %s=%s." ), " -debugexclude" , cat));
925
+ continue ;
931
926
}
927
+ logCategories &= ~flag;
932
928
}
933
929
934
930
// Check for -debugnet
@@ -1238,13 +1234,10 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1238
1234
1239
1235
// sanitize comments per BIP-0014, format user agent and check total size
1240
1236
std::vector<std::string> uacomments;
1241
- if (gArgs .IsArgSet (" -uacomment" )) {
1242
- for (std::string cmt : gArgs .GetArgs (" -uacomment" ))
1243
- {
1244
- if (cmt != SanitizeString (cmt, SAFE_CHARS_UA_COMMENT))
1245
- return InitError (strprintf (_ (" User Agent comment (%s) contains unsafe characters." ), cmt));
1246
- uacomments.push_back (cmt);
1247
- }
1237
+ for (const std::string& cmt : gArgs .GetArgs (" -uacomment" )) {
1238
+ if (cmt != SanitizeString (cmt, SAFE_CHARS_UA_COMMENT))
1239
+ return InitError (strprintf (_ (" User Agent comment (%s) contains unsafe characters." ), cmt));
1240
+ uacomments.push_back (cmt);
1248
1241
}
1249
1242
strSubVersion = FormatSubVersion (CLIENT_NAME, CLIENT_VERSION, uacomments);
1250
1243
if (strSubVersion.size () > MAX_SUBVERSION_LENGTH) {
@@ -1317,14 +1310,12 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1317
1310
fDiscover = GetBoolArg (" -discover" , true );
1318
1311
fRelayTxes = !GetBoolArg (" -blocksonly" , DEFAULT_BLOCKSONLY);
1319
1312
1320
- if (gArgs .IsArgSet (" -externalip" )) {
1321
- for (const std::string& strAddr : gArgs .GetArgs (" -externalip" )) {
1322
- CService addrLocal;
1323
- if (Lookup (strAddr.c_str (), addrLocal, GetListenPort (), fNameLookup ) && addrLocal.IsValid ())
1324
- AddLocal (addrLocal, LOCAL_MANUAL);
1325
- else
1326
- return InitError (ResolveErrMsg (" externalip" , strAddr));
1327
- }
1313
+ for (const std::string& strAddr : gArgs .GetArgs (" -externalip" )) {
1314
+ CService addrLocal;
1315
+ if (Lookup (strAddr.c_str (), addrLocal, GetListenPort (), fNameLookup ) && addrLocal.IsValid ())
1316
+ AddLocal (addrLocal, LOCAL_MANUAL);
1317
+ else
1318
+ return InitError (ResolveErrMsg (" externalip" , strAddr));
1328
1319
}
1329
1320
1330
1321
#if ENABLE_ZMQ
@@ -1553,10 +1544,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1553
1544
uiInterface.NotifyBlockTip .connect (BlockNotifyCallback);
1554
1545
1555
1546
std::vector<fs::path> vImportFiles;
1556
- if (gArgs .IsArgSet (" -loadblock" ))
1557
- {
1558
- for (const std::string& strFile : gArgs .GetArgs (" -loadblock" ))
1559
- vImportFiles.push_back (strFile);
1547
+ for (const std::string& strFile : gArgs .GetArgs (" -loadblock" )) {
1548
+ vImportFiles.push_back (strFile);
1560
1549
}
1561
1550
1562
1551
threadGroup.create_thread (boost::bind (&ThreadImport, vImportFiles));
@@ -1598,36 +1587,30 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
1598
1587
connOptions.nMaxOutboundTimeframe = nMaxOutboundTimeframe;
1599
1588
connOptions.nMaxOutboundLimit = nMaxOutboundLimit;
1600
1589
1601
- if (gArgs .IsArgSet (" -bind" )) {
1602
- for (const std::string& strBind : gArgs .GetArgs (" -bind" )) {
1603
- CService addrBind;
1604
- if (!Lookup (strBind.c_str (), addrBind, GetListenPort (), false )) {
1605
- return InitError (ResolveErrMsg (" bind" , strBind));
1606
- }
1607
- connOptions.vBinds .push_back (addrBind);
1590
+ for (const std::string& strBind : gArgs .GetArgs (" -bind" )) {
1591
+ CService addrBind;
1592
+ if (!Lookup (strBind.c_str (), addrBind, GetListenPort (), false )) {
1593
+ return InitError (ResolveErrMsg (" bind" , strBind));
1608
1594
}
1595
+ connOptions.vBinds .push_back (addrBind);
1609
1596
}
1610
- if (gArgs .IsArgSet (" -whitebind" )) {
1611
- for (const std::string& strBind : gArgs .GetArgs (" -whitebind" )) {
1612
- CService addrBind;
1613
- if (!Lookup (strBind.c_str (), addrBind, 0 , false )) {
1614
- return InitError (ResolveErrMsg (" whitebind" , strBind));
1615
- }
1616
- if (addrBind.GetPort () == 0 ) {
1617
- return InitError (strprintf (_ (" Need to specify a port with -whitebind: '%s'" ), strBind));
1618
- }
1619
- connOptions.vWhiteBinds .push_back (addrBind);
1597
+ for (const std::string& strBind : gArgs .GetArgs (" -whitebind" )) {
1598
+ CService addrBind;
1599
+ if (!Lookup (strBind.c_str (), addrBind, 0 , false )) {
1600
+ return InitError (ResolveErrMsg (" whitebind" , strBind));
1601
+ }
1602
+ if (addrBind.GetPort () == 0 ) {
1603
+ return InitError (strprintf (_ (" Need to specify a port with -whitebind: '%s'" ), strBind));
1620
1604
}
1605
+ connOptions.vWhiteBinds .push_back (addrBind);
1621
1606
}
1622
1607
1623
- if (gArgs .IsArgSet (" -whitelist" )) {
1624
- for (const auto & net : gArgs .GetArgs (" -whitelist" )) {
1625
- CSubNet subnet;
1626
- LookupSubNet (net.c_str (), subnet);
1627
- if (!subnet.IsValid ())
1628
- return InitError (strprintf (_ (" Invalid netmask specified in -whitelist: '%s'" ), net));
1629
- connOptions.vWhitelistedRange .push_back (subnet);
1630
- }
1608
+ for (const auto & net : gArgs .GetArgs (" -whitelist" )) {
1609
+ CSubNet subnet;
1610
+ LookupSubNet (net.c_str (), subnet);
1611
+ if (!subnet.IsValid ())
1612
+ return InitError (strprintf (_ (" Invalid netmask specified in -whitelist: '%s'" ), net));
1613
+ connOptions.vWhitelistedRange .push_back (subnet);
1631
1614
}
1632
1615
1633
1616
if (gArgs .IsArgSet (" -seednode" )) {
0 commit comments