Startup -addnode values are copied directly into the connection manager's added-node list. Unlike runtime addnode add calls, this path does not reject repeated values.
For example:
-addnode=example.com
-addnode=example.com
-addnode=example.com:8333
All three entries are currently stored, although on mainnet they refer to the same peer. While the destination is disconnected, ThreadOpenAddedConnections() processes each entry during every retry cycle.
This can cause redundant DNS lookups, connection attempts, and log messages. getaddednodeinfo also reports the repeated entries.
This PR checks each startup value with the same lookup that addnode add uses, keeps the first entry, and logs a warning for each ignored value naming the entry it matched.
Two values refer to the same peer if they are the same string, the same numeric address (e.g. [::1] and [0:0:0:0:0:0:0:1]), or the same host and effective port (e.g. example.com and example.com:8333 on mainnet). No DNS lookups are done.
To keep the added-node handling consistent, it also:
- makes
addnode addreject a host that was already added with or without the default port; - makes
addnode removeandgetaddednodeinfo <node>accept any equivalent value, so they no longer report a value as not added afteraddnode addrejected it as already added; - makes
AddedNodesContain(), which keeps automatic outbound connections away from addnode peers, match numeric aliases. On master, an added node written as[2001:db8::1]or as an expanded IPv6 address is never matched, and deduplicating startup values could otherwise keep such a spelling instead of one that matches.
A release note is included.
This change is complementary to, and independent of, #35600.
#35600 prevents overlapping manual connection attempts by tracking destinations while a connection attempt is in progress.
This PR instead removes repeated -addnode values before the connection threads start, preventing duplicate stored entries and sequential redundant retries.
It does not replace or broaden #35600's in-flight connection handling.