aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-06-27 14:22:54 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2017-06-27 16:29:11 +0200
commitac52492cd22782d7b09c78c198fb6fd8eb1da57c (patch)
treee02f1da9e4323a3dcf37b829dcf87656983a0d4d /src/init.cpp
parent7c87a9c748be7121a240d81f9a5c6c988be6ffcf (diff)
parented866ab923c01d9da2ddd067144e74978383e304 (diff)
downloadbitcoin-ac52492cd22782d7b09c78c198fb6fd8eb1da57c.tar.xz
Merge #10118: Util: Remove redundant calls to argsGlobal.IsArgSet()
ed866ab Indentation after 'Remove redundant calls to gArgs.IsArgSet()' (Jorge Timón) 506b700 Util: Remove redundant calls to gArgs.IsArgSet() (Jorge Timón) Tree-SHA512: 4f97a0bf2a76c0f351a6343db62898cf057d745c848de00fa09465e870a120f28e0d836cafd6a047f4ec0da7ab671aebee43fa7410c9f0e66382edd1bb2009ba
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp93
1 files changed, 38 insertions, 55 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 88084cbeec..57232c7df3 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -880,9 +880,7 @@ bool AppInitParameterInteraction()
}
// -bind and -whitebind can't be set when not listening
- size_t nUserBind =
- (gArgs.IsArgSet("-bind") ? gArgs.GetArgs("-bind").size() : 0) +
- (gArgs.IsArgSet("-whitebind") ? gArgs.GetArgs("-whitebind").size() : 0);
+ size_t nUserBind = gArgs.GetArgs("-bind").size() + gArgs.GetArgs("-whitebind").size();
if (nUserBind != 0 && !gArgs.GetBoolArg("-listen", DEFAULT_LISTEN)) {
return InitError("Cannot set -bind or -whitebind together with -listen=0");
}
@@ -920,15 +918,13 @@ bool AppInitParameterInteraction()
}
// Now remove the logging categories which were explicitly excluded
- if (gArgs.IsArgSet("-debugexclude")) {
- for (const std::string& cat : gArgs.GetArgs("-debugexclude")) {
- uint32_t flag = 0;
- if (!GetLogCategory(&flag, &cat)) {
- InitWarning(strprintf(_("Unsupported logging category %s=%s."), "-debugexclude", cat));
- continue;
- }
- logCategories &= ~flag;
+ for (const std::string& cat : gArgs.GetArgs("-debugexclude")) {
+ uint32_t flag = 0;
+ if (!GetLogCategory(&flag, &cat)) {
+ InitWarning(strprintf(_("Unsupported logging category %s=%s."), "-debugexclude", cat));
+ continue;
}
+ logCategories &= ~flag;
}
// Check for -debugnet
@@ -1238,13 +1234,10 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
// sanitize comments per BIP-0014, format user agent and check total size
std::vector<std::string> uacomments;
- if (gArgs.IsArgSet("-uacomment")) {
- for (std::string cmt : gArgs.GetArgs("-uacomment"))
- {
- if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT))
- return InitError(strprintf(_("User Agent comment (%s) contains unsafe characters."), cmt));
- uacomments.push_back(cmt);
- }
+ for (const std::string& cmt : gArgs.GetArgs("-uacomment")) {
+ if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT))
+ return InitError(strprintf(_("User Agent comment (%s) contains unsafe characters."), cmt));
+ uacomments.push_back(cmt);
}
strSubVersion = FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, uacomments);
if (strSubVersion.size() > MAX_SUBVERSION_LENGTH) {
@@ -1317,14 +1310,12 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
fDiscover = GetBoolArg("-discover", true);
fRelayTxes = !GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY);
- if (gArgs.IsArgSet("-externalip")) {
- for (const std::string& strAddr : gArgs.GetArgs("-externalip")) {
- CService addrLocal;
- if (Lookup(strAddr.c_str(), addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid())
- AddLocal(addrLocal, LOCAL_MANUAL);
- else
- return InitError(ResolveErrMsg("externalip", strAddr));
- }
+ for (const std::string& strAddr : gArgs.GetArgs("-externalip")) {
+ CService addrLocal;
+ if (Lookup(strAddr.c_str(), addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid())
+ AddLocal(addrLocal, LOCAL_MANUAL);
+ else
+ return InitError(ResolveErrMsg("externalip", strAddr));
}
#if ENABLE_ZMQ
@@ -1553,10 +1544,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback);
std::vector<fs::path> vImportFiles;
- if (gArgs.IsArgSet("-loadblock"))
- {
- for (const std::string& strFile : gArgs.GetArgs("-loadblock"))
- vImportFiles.push_back(strFile);
+ for (const std::string& strFile : gArgs.GetArgs("-loadblock")) {
+ vImportFiles.push_back(strFile);
}
threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles));
@@ -1598,36 +1587,30 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
connOptions.nMaxOutboundTimeframe = nMaxOutboundTimeframe;
connOptions.nMaxOutboundLimit = nMaxOutboundLimit;
- if (gArgs.IsArgSet("-bind")) {
- for (const std::string& strBind : gArgs.GetArgs("-bind")) {
- CService addrBind;
- if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false)) {
- return InitError(ResolveErrMsg("bind", strBind));
- }
- connOptions.vBinds.push_back(addrBind);
+ for (const std::string& strBind : gArgs.GetArgs("-bind")) {
+ CService addrBind;
+ if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false)) {
+ return InitError(ResolveErrMsg("bind", strBind));
}
+ connOptions.vBinds.push_back(addrBind);
}
- if (gArgs.IsArgSet("-whitebind")) {
- for (const std::string& strBind : gArgs.GetArgs("-whitebind")) {
- CService addrBind;
- if (!Lookup(strBind.c_str(), addrBind, 0, false)) {
- return InitError(ResolveErrMsg("whitebind", strBind));
- }
- if (addrBind.GetPort() == 0) {
- return InitError(strprintf(_("Need to specify a port with -whitebind: '%s'"), strBind));
- }
- connOptions.vWhiteBinds.push_back(addrBind);
+ for (const std::string& strBind : gArgs.GetArgs("-whitebind")) {
+ CService addrBind;
+ if (!Lookup(strBind.c_str(), addrBind, 0, false)) {
+ return InitError(ResolveErrMsg("whitebind", strBind));
+ }
+ if (addrBind.GetPort() == 0) {
+ return InitError(strprintf(_("Need to specify a port with -whitebind: '%s'"), strBind));
}
+ connOptions.vWhiteBinds.push_back(addrBind);
}
- if (gArgs.IsArgSet("-whitelist")) {
- for (const auto& net : gArgs.GetArgs("-whitelist")) {
- CSubNet subnet;
- LookupSubNet(net.c_str(), subnet);
- if (!subnet.IsValid())
- return InitError(strprintf(_("Invalid netmask specified in -whitelist: '%s'"), net));
- connOptions.vWhitelistedRange.push_back(subnet);
- }
+ for (const auto& net : gArgs.GetArgs("-whitelist")) {
+ CSubNet subnet;
+ LookupSubNet(net.c_str(), subnet);
+ if (!subnet.IsValid())
+ return InitError(strprintf(_("Invalid netmask specified in -whitelist: '%s'"), net));
+ connOptions.vWhitelistedRange.push_back(subnet);
}
if (gArgs.IsArgSet("-seednode")) {