Skip to content

Commit 458ef0a

Browse files
committed
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.
1 parent 752ab9c commit 458ef0a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/init.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,9 @@ void InitParameterInteraction(ArgsManager& args)
725725
LogInfo("parameter interaction: -whitebind set -> setting -listen=1\n");
726726
}
727727

728-
if (args.IsArgSet("-connect") || args.GetIntArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS) <= 0) {
728+
if (!args.GetArgs("-connect").empty() || args.IsArgNegated("-connect") || args.GetIntArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS) <= 0) {
729729
// when only connecting to trusted nodes, do not seed via DNS, or listen by default
730+
// do the same when connections are disabled
730731
if (args.SoftSetBoolArg("-dnsseed", false))
731732
LogInfo("parameter interaction: -connect or -maxconnections=0 set -> setting -dnsseed=0\n");
732733
if (args.SoftSetBoolArg("-listen", false))
@@ -1995,10 +1996,12 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
19951996

19961997
connOptions.vSeedNodes = args.GetArgs("-seednode");
19971998

1998-
// Initiate outbound connections unless connect=0
1999-
connOptions.m_use_addrman_outgoing = !args.IsArgSet("-connect");
2000-
if (!connOptions.m_use_addrman_outgoing) {
2001-
const auto connect = args.GetArgs("-connect");
1999+
const auto connect = args.GetArgs("-connect");
2000+
if (!connect.empty() || args.IsArgNegated("-connect")) {
2001+
// Do not initiate other outgoing connections when connecting to trusted
2002+
// nodes, or when -noconnect is specified.
2003+
connOptions.m_use_addrman_outgoing = false;
2004+
20022005
if (connect.size() != 1 || connect[0] != "0") {
20032006
connOptions.m_specified_outgoing = connect;
20042007
}

0 commit comments

Comments
 (0)