mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 12:22:50 -05:00
refactor: Avoid using IsArgSet() on -connect list option
This commit does not change behavior, it just changes code to handle -noconnect values explicitly with IsArgNegated() instead of implicitly with IsArgSet(), and adds comments to make it clear what behavior is intended when -noconnect is specified.
This commit is contained in:
parent
752ab9c3c6
commit
458ef0a11b
1 changed files with 8 additions and 5 deletions
13
src/init.cpp
13
src/init.cpp
|
@ -725,8 +725,9 @@ void InitParameterInteraction(ArgsManager& args)
|
|||
LogInfo("parameter interaction: -whitebind set -> setting -listen=1\n");
|
||||
}
|
||||
|
||||
if (args.IsArgSet("-connect") || args.GetIntArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS) <= 0) {
|
||||
if (!args.GetArgs("-connect").empty() || args.IsArgNegated("-connect") || args.GetIntArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS) <= 0) {
|
||||
// when only connecting to trusted nodes, do not seed via DNS, or listen by default
|
||||
// do the same when connections are disabled
|
||||
if (args.SoftSetBoolArg("-dnsseed", false))
|
||||
LogInfo("parameter interaction: -connect or -maxconnections=0 set -> setting -dnsseed=0\n");
|
||||
if (args.SoftSetBoolArg("-listen", false))
|
||||
|
@ -1995,10 +1996,12 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
|
||||
connOptions.vSeedNodes = args.GetArgs("-seednode");
|
||||
|
||||
// Initiate outbound connections unless connect=0
|
||||
connOptions.m_use_addrman_outgoing = !args.IsArgSet("-connect");
|
||||
if (!connOptions.m_use_addrman_outgoing) {
|
||||
const auto connect = args.GetArgs("-connect");
|
||||
const auto connect = args.GetArgs("-connect");
|
||||
if (!connect.empty() || args.IsArgNegated("-connect")) {
|
||||
// Do not initiate other outgoing connections when connecting to trusted
|
||||
// nodes, or when -noconnect is specified.
|
||||
connOptions.m_use_addrman_outgoing = false;
|
||||
|
||||
if (connect.size() != 1 || connect[0] != "0") {
|
||||
connOptions.m_specified_outgoing = connect;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue