|
|
@ -741,7 +741,7 @@ void InitParameterInteraction() |
|
|
|
LogPrintf("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__); |
|
|
|
LogPrintf("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mapMultiArgs.count("-connect") && mapMultiArgs.at("-connect").size() > 0) { |
|
|
|
if (gArgs.IsArgSet("-connect") && gArgs.GetArgs("-connect").size() > 0) { |
|
|
|
// when only connecting to trusted nodes, do not seed via DNS, or listen by default
|
|
|
|
// when only connecting to trusted nodes, do not seed via DNS, or listen by default
|
|
|
|
if (SoftSetBoolArg("-dnsseed", false)) |
|
|
|
if (SoftSetBoolArg("-dnsseed", false)) |
|
|
|
LogPrintf("%s: parameter interaction: -connect set -> setting -dnsseed=0\n", __func__); |
|
|
|
LogPrintf("%s: parameter interaction: -connect set -> setting -dnsseed=0\n", __func__); |
|
|
@ -895,8 +895,8 @@ bool AppInitParameterInteraction() |
|
|
|
|
|
|
|
|
|
|
|
// Make sure enough file descriptors are available
|
|
|
|
// Make sure enough file descriptors are available
|
|
|
|
int nBind = std::max( |
|
|
|
int nBind = std::max( |
|
|
|
(mapMultiArgs.count("-bind") ? mapMultiArgs.at("-bind").size() : 0) + |
|
|
|
(gArgs.IsArgSet("-bind") ? gArgs.GetArgs("-bind").size() : 0) + |
|
|
|
(mapMultiArgs.count("-whitebind") ? mapMultiArgs.at("-whitebind").size() : 0), size_t(1)); |
|
|
|
(gArgs.IsArgSet("-whitebind") ? gArgs.GetArgs("-whitebind").size() : 0), size_t(1)); |
|
|
|
nUserMaxConnections = GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS); |
|
|
|
nUserMaxConnections = GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS); |
|
|
|
nMaxConnections = std::max(nUserMaxConnections, 0); |
|
|
|
nMaxConnections = std::max(nUserMaxConnections, 0); |
|
|
|
|
|
|
|
|
|
|
@ -911,9 +911,9 @@ bool AppInitParameterInteraction() |
|
|
|
InitWarning(strprintf(_("Reducing -maxconnections from %d to %d, because of system limitations."), nUserMaxConnections, nMaxConnections)); |
|
|
|
InitWarning(strprintf(_("Reducing -maxconnections from %d to %d, because of system limitations."), nUserMaxConnections, nMaxConnections)); |
|
|
|
|
|
|
|
|
|
|
|
// ********************************************************* Step 3: parameter-to-internal-flags
|
|
|
|
// ********************************************************* Step 3: parameter-to-internal-flags
|
|
|
|
if (mapMultiArgs.count("-debug") > 0) { |
|
|
|
if (gArgs.IsArgSet("-debug") > 0) { |
|
|
|
// Special-case: if -debug=0/-nodebug is set, turn off debugging messages
|
|
|
|
// Special-case: if -debug=0/-nodebug is set, turn off debugging messages
|
|
|
|
const std::vector<std::string>& categories = mapMultiArgs.at("-debug"); |
|
|
|
const std::vector<std::string>& categories = gArgs.GetArgs("-debug"); |
|
|
|
|
|
|
|
|
|
|
|
if (find(categories.begin(), categories.end(), std::string("0")) == categories.end()) { |
|
|
|
if (find(categories.begin(), categories.end(), std::string("0")) == categories.end()) { |
|
|
|
for (const auto& cat : categories) { |
|
|
|
for (const auto& cat : categories) { |
|
|
@ -928,8 +928,8 @@ bool AppInitParameterInteraction() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Now remove the logging categories which were explicitly excluded
|
|
|
|
// Now remove the logging categories which were explicitly excluded
|
|
|
|
if (mapMultiArgs.count("-debugexclude") > 0) { |
|
|
|
if (gArgs.IsArgSet("-debugexclude") > 0) { |
|
|
|
const std::vector<std::string>& excludedCategories = mapMultiArgs.at("-debugexclude"); |
|
|
|
const std::vector<std::string>& excludedCategories = gArgs.GetArgs("-debugexclude"); |
|
|
|
for (const auto& cat : excludedCategories) { |
|
|
|
for (const auto& cat : excludedCategories) { |
|
|
|
uint32_t flag = 0; |
|
|
|
uint32_t flag = 0; |
|
|
|
if (!GetLogCategory(&flag, &cat)) { |
|
|
|
if (!GetLogCategory(&flag, &cat)) { |
|
|
@ -1100,12 +1100,12 @@ bool AppInitParameterInteraction() |
|
|
|
fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "fee") != vstrReplacementModes.end()); |
|
|
|
fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "fee") != vstrReplacementModes.end()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mapMultiArgs.count("-bip9params")) { |
|
|
|
if (gArgs.IsArgSet("-bip9params")) { |
|
|
|
// Allow overriding BIP9 parameters for testing
|
|
|
|
// Allow overriding BIP9 parameters for testing
|
|
|
|
if (!chainparams.MineBlocksOnDemand()) { |
|
|
|
if (!chainparams.MineBlocksOnDemand()) { |
|
|
|
return InitError("BIP9 parameters may only be overridden on regtest."); |
|
|
|
return InitError("BIP9 parameters may only be overridden on regtest."); |
|
|
|
} |
|
|
|
} |
|
|
|
const std::vector<std::string>& deployments = mapMultiArgs.at("-bip9params"); |
|
|
|
const std::vector<std::string>& deployments = gArgs.GetArgs("-bip9params"); |
|
|
|
for (auto i : deployments) { |
|
|
|
for (auto i : deployments) { |
|
|
|
std::vector<std::string> vDeploymentParams; |
|
|
|
std::vector<std::string> vDeploymentParams; |
|
|
|
boost::split(vDeploymentParams, i, boost::is_any_of(":")); |
|
|
|
boost::split(vDeploymentParams, i, boost::is_any_of(":")); |
|
|
@ -1254,8 +1254,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) |
|
|
|
|
|
|
|
|
|
|
|
// sanitize comments per BIP-0014, format user agent and check total size
|
|
|
|
// sanitize comments per BIP-0014, format user agent and check total size
|
|
|
|
std::vector<std::string> uacomments; |
|
|
|
std::vector<std::string> uacomments; |
|
|
|
if (mapMultiArgs.count("-uacomment")) { |
|
|
|
if (gArgs.IsArgSet("-uacomment")) { |
|
|
|
BOOST_FOREACH(std::string cmt, mapMultiArgs.at("-uacomment")) |
|
|
|
BOOST_FOREACH(std::string cmt, gArgs.GetArgs("-uacomment")) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT)) |
|
|
|
if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT)) |
|
|
|
return InitError(strprintf(_("User Agent comment (%s) contains unsafe characters."), cmt)); |
|
|
|
return InitError(strprintf(_("User Agent comment (%s) contains unsafe characters."), cmt)); |
|
|
@ -1268,9 +1268,9 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) |
|
|
|
strSubVersion.size(), MAX_SUBVERSION_LENGTH)); |
|
|
|
strSubVersion.size(), MAX_SUBVERSION_LENGTH)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mapMultiArgs.count("-onlynet")) { |
|
|
|
if (gArgs.IsArgSet("-onlynet")) { |
|
|
|
std::set<enum Network> nets; |
|
|
|
std::set<enum Network> nets; |
|
|
|
BOOST_FOREACH(const std::string& snet, mapMultiArgs.at("-onlynet")) { |
|
|
|
BOOST_FOREACH(const std::string& snet, gArgs.GetArgs("-onlynet")) { |
|
|
|
enum Network net = ParseNetwork(snet); |
|
|
|
enum Network net = ParseNetwork(snet); |
|
|
|
if (net == NET_UNROUTABLE) |
|
|
|
if (net == NET_UNROUTABLE) |
|
|
|
return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet)); |
|
|
|
return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet)); |
|
|
@ -1283,8 +1283,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mapMultiArgs.count("-whitelist")) { |
|
|
|
if (gArgs.IsArgSet("-whitelist")) { |
|
|
|
BOOST_FOREACH(const std::string& net, mapMultiArgs.at("-whitelist")) { |
|
|
|
BOOST_FOREACH(const std::string& net, gArgs.GetArgs("-whitelist")) { |
|
|
|
CSubNet subnet; |
|
|
|
CSubNet subnet; |
|
|
|
LookupSubNet(net.c_str(), subnet); |
|
|
|
LookupSubNet(net.c_str(), subnet); |
|
|
|
if (!subnet.IsValid()) |
|
|
|
if (!subnet.IsValid()) |
|
|
@ -1345,16 +1345,16 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) |
|
|
|
|
|
|
|
|
|
|
|
if (fListen) { |
|
|
|
if (fListen) { |
|
|
|
bool fBound = false; |
|
|
|
bool fBound = false; |
|
|
|
if (mapMultiArgs.count("-bind")) { |
|
|
|
if (gArgs.IsArgSet("-bind")) { |
|
|
|
BOOST_FOREACH(const std::string& strBind, mapMultiArgs.at("-bind")) { |
|
|
|
BOOST_FOREACH(const std::string& strBind, gArgs.GetArgs("-bind")) { |
|
|
|
CService addrBind; |
|
|
|
CService addrBind; |
|
|
|
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false)) |
|
|
|
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false)) |
|
|
|
return InitError(ResolveErrMsg("bind", strBind)); |
|
|
|
return InitError(ResolveErrMsg("bind", strBind)); |
|
|
|
fBound |= Bind(connman, addrBind, (BF_EXPLICIT | BF_REPORT_ERROR)); |
|
|
|
fBound |= Bind(connman, addrBind, (BF_EXPLICIT | BF_REPORT_ERROR)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (mapMultiArgs.count("-whitebind")) { |
|
|
|
if (gArgs.IsArgSet("-whitebind")) { |
|
|
|
BOOST_FOREACH(const std::string& strBind, mapMultiArgs.at("-whitebind")) { |
|
|
|
BOOST_FOREACH(const std::string& strBind, gArgs.GetArgs("-whitebind")) { |
|
|
|
CService addrBind; |
|
|
|
CService addrBind; |
|
|
|
if (!Lookup(strBind.c_str(), addrBind, 0, false)) |
|
|
|
if (!Lookup(strBind.c_str(), addrBind, 0, false)) |
|
|
|
return InitError(ResolveErrMsg("whitebind", strBind)); |
|
|
|
return InitError(ResolveErrMsg("whitebind", strBind)); |
|
|
@ -1363,7 +1363,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) |
|
|
|
fBound |= Bind(connman, addrBind, (BF_EXPLICIT | BF_REPORT_ERROR | BF_WHITELIST)); |
|
|
|
fBound |= Bind(connman, addrBind, (BF_EXPLICIT | BF_REPORT_ERROR | BF_WHITELIST)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (!mapMultiArgs.count("-bind") && !mapMultiArgs.count("-whitebind")) { |
|
|
|
if (!gArgs.IsArgSet("-bind") && !gArgs.IsArgSet("-whitebind")) { |
|
|
|
struct in_addr inaddr_any; |
|
|
|
struct in_addr inaddr_any; |
|
|
|
inaddr_any.s_addr = INADDR_ANY; |
|
|
|
inaddr_any.s_addr = INADDR_ANY; |
|
|
|
fBound |= Bind(connman, CService(in6addr_any, GetListenPort()), BF_NONE); |
|
|
|
fBound |= Bind(connman, CService(in6addr_any, GetListenPort()), BF_NONE); |
|
|
@ -1373,8 +1373,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) |
|
|
|
return InitError(_("Failed to listen on any port. Use -listen=0 if you want this.")); |
|
|
|
return InitError(_("Failed to listen on any port. Use -listen=0 if you want this.")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mapMultiArgs.count("-externalip")) { |
|
|
|
if (gArgs.IsArgSet("-externalip")) { |
|
|
|
BOOST_FOREACH(const std::string& strAddr, mapMultiArgs.at("-externalip")) { |
|
|
|
BOOST_FOREACH(const std::string& strAddr, gArgs.GetArgs("-externalip")) { |
|
|
|
CService addrLocal; |
|
|
|
CService addrLocal; |
|
|
|
if (Lookup(strAddr.c_str(), addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid()) |
|
|
|
if (Lookup(strAddr.c_str(), addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid()) |
|
|
|
AddLocal(addrLocal, LOCAL_MANUAL); |
|
|
|
AddLocal(addrLocal, LOCAL_MANUAL); |
|
|
@ -1383,8 +1383,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mapMultiArgs.count("-seednode")) { |
|
|
|
if (gArgs.IsArgSet("-seednode")) { |
|
|
|
BOOST_FOREACH(const std::string& strDest, mapMultiArgs.at("-seednode")) |
|
|
|
BOOST_FOREACH(const std::string& strDest, gArgs.GetArgs("-seednode")) |
|
|
|
connman.AddOneShot(strDest); |
|
|
|
connman.AddOneShot(strDest); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1610,9 +1610,9 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) |
|
|
|
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback); |
|
|
|
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback); |
|
|
|
|
|
|
|
|
|
|
|
std::vector<fs::path> vImportFiles; |
|
|
|
std::vector<fs::path> vImportFiles; |
|
|
|
if (mapMultiArgs.count("-loadblock")) |
|
|
|
if (gArgs.IsArgSet("-loadblock")) |
|
|
|
{ |
|
|
|
{ |
|
|
|
BOOST_FOREACH(const std::string& strFile, mapMultiArgs.at("-loadblock")) |
|
|
|
BOOST_FOREACH(const std::string& strFile, gArgs.GetArgs("-loadblock")) |
|
|
|
vImportFiles.push_back(strFile); |
|
|
|
vImportFiles.push_back(strFile); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|