init: ignore repeated `-addnode` startup values #36014

pull w0xlt wants to merge 1 commits into bitcoin:master from w0xlt:net-deduplicate-startup-addnodes changing 2 files +23 −0
  1. w0xlt commented at 8:28 PM on August 18, 2026: contributor

    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
    

    Both entries are currently stored. 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 entry.


    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.

  2. init: ignore duplicate -addnode values
    Startup -addnode values are copied directly into CConnman state, so
    exact duplicates are stored and retried independently whenever the
    destination is disconnected.
    
    Keep only the first exact value during startup argument processing.
    This does not resolve aliases or change in-flight manual connection
    handling.
    073a33247e
  3. DrahtBot commented at 8:28 PM on August 18, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36014.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    Concept ACK pablomartin4btc

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #35940 (net: allow selecting BIP152 high-bandwidth peers with -addnode by w0xlt)
    • #31260 (scripted-diff: Type-safe settings retrieval by ryanofsky)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. pablomartin4btc commented at 6:30 PM on August 19, 2026: member

    Concept ACK

    Comparing this patch to the validation performed in CConnman::AddNode() (the RPC path), which resolves the target — full resolution is out of scope as clearly explained in the description and commit body. What about also checking the port (perhaps using SplitHostPort), so e.g. node.example and node.example:8333 (mainnet default port) would be treated as the same target, and the second one excluded as a duplicate?


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-08-21 04:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me