addrman: make `m_last_good` network-specific #35750

pull mzumsande wants to merge 2 commits into bitcoin:master from mzumsande:202607_addrman_last_good changing 3 files +61 −4
  1. mzumsande commented at 9:55 PM on July 19, 2026: contributor

    m_last_good is used to prevent recording failed attempts for addresses when it is our connectivity that is at fault. However, it is quite common that only some networks are unreachable - e.g. I have encountered it frequently that IPv6 is unreachable, while IPv4 works fine. In this case it is not correct to increase the failed counter for an IPv6 address and ultimately making it Terrible, just because we are making IPv4 connections.

    Fix this by making m_last_good network-specific. Also change the initial value from 1 to 0, so that in a situation when there was no previous attempt for an address, but also no previous successful connection to its network, the failed count is not increased. The intial value was not a major issue previously because we would only count failures after having at least two outbound connections (in which case m_last_good would have been set).

  2. addrman: don't count connection failures before the first success
    m_last_good was initialised to 1 instead of 0, so that an entry whose
    m_last_count_attempt is still 0 is eligible for one counted failure even
    though we have never connected to anything successfully.
    
    In practice, this makes little difference: net.cpp normally only passes
    fCountFailure once we have at least two outbound peers, which implies
    that Good() has already been called.
    However, it is changed here in preparation of making m_last_good a
    network-specific array.
    b8840fd1c6
  3. DrahtBot added the label P2P on Jul 19, 2026
  4. DrahtBot commented at 9:55 PM on July 19, 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/35750.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    Type Reviewers
    Concept ACK fjahr

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. addrman: make m_last_good network-specific
    Attempt_() only counts a failed connection attempt if
    we have made a successful connection since the last attempt,
    so that we don't blame addresses for our own lack of connectivity.
    This was network-agnostic: successful connections on any
    network re-enabled the check for all addresses.
    
    As a result, a network that is unreachable for us while others keep
    working - e.g. if IPv6 is not reachable, or a non-working Tor proxy -
    would lead to addresses of that network becoming Terrible.
    
    Avoid this by tracking the last successful connection per
    network instead.
    31191b5239
  6. mzumsande force-pushed on Jul 19, 2026
  7. DrahtBot added the label CI failed on Jul 19, 2026
  8. DrahtBot removed the label CI failed on Jul 19, 2026
  9. fjahr commented at 8:29 AM on July 20, 2026: contributor

    Concept ACK

Labels

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-07-22 07:50 UTC

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