refactor: Use NodeClock::time_point for m_addr_token_timestamp #34059

pull maflcko wants to merge 10 commits into bitcoin:master from maflcko:2512-net-less-GetTime changing 13 files +325 −318
  1. maflcko commented at 2:15 pm on December 12, 2025: member

    It is a bit confusing to have some code use the deprecated GetTime, which returns a duration and not a time point, and other code to use NodeClock time points.

    Fix one place m_addr_token_timestamp to use NodeClock::time_point.

    Also:

    • Extract a ProcessAddrs helper, similar to the other Process*() helpers, to cut down the ProcessMessage with a massive scope.
    • Rename the confusing current_a_time to now_seconds. (The a in this context refers to the removed “adjusted” time, see commit fadd8b2676f6d68ec87189871461c9a6a6aa3cac, which removed adjusted time here)
    • Clean-up a test, to make ProcessMessage private again. Also, change pointers to references to avoid the mental and literal overhead of (redundantly) checking for nullptr every time.
  2. DrahtBot renamed this:
    refactor: Use NodeClock::time_point for m_addr_token_timestamp
    refactor: Use NodeClock::time_point for m_addr_token_timestamp
    on Dec 12, 2025
  3. DrahtBot added the label Refactoring on Dec 12, 2025
  4. DrahtBot commented at 2:15 pm on December 12, 2025: contributor

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

    Code Coverage & Benchmarks

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Approach ACK ajtowns

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34181 (refactor: [p2p] Make ProcessMessage private again, Use references when non-null by maflcko)
    • #33854 (fix assumevalid is ignored during reindex by Eunovo)
    • #32278 (doc: better document NetEventsInterface and the deletion of “CNode"s by vasild)
    • #31650 (refactor: Avoid copies by using const references or by move-construction by maflcko)
    • #29415 (Broadcast own transactions only via short-lived Tor or I2P connections by vasild)
    • #27052 (test: rpc: add last block announcement time to getpeerinfo result by LarryRuane)

    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.

  5. ajtowns commented at 11:45 pm on December 12, 2025: contributor

    What do you think of getting all the peer->foo to peer.foo noise done first, rather than doing it bit by bit? Here’s a scripted-diff approach that might be easy to review: https://github.com/ajtowns/bitcoin/commits/202512-peer-by-ref/

    Approach ACK otherwise

  6. maflcko marked this as a draft on Dec 15, 2025
  7. maflcko force-pushed on Dec 16, 2025
  8. maflcko marked this as ready for review on Dec 16, 2025
  9. maflcko force-pushed on Dec 16, 2025
  10. DrahtBot added the label CI failed on Dec 16, 2025
  11. maflcko force-pushed on Dec 16, 2025
  12. maflcko commented at 9:40 am on December 16, 2025: member

    What do you think of getting all the peer->foo to peer.foo noise done first, rather than doing it bit by bit? Here’s a scripted-diff approach that might be easy to review: https://github.com/ajtowns/bitcoin/commits/202512-peer-by-ref/

    Nice branch. I re-created it to avoid refactoring real code to accommodate tests, which are better served by just using the pre-existing ConnmanTestMsg helpers.

  13. DrahtBot removed the label CI failed on Dec 16, 2025
  14. DrahtBot added the label Needs rebase on Dec 16, 2025
  15. test: [refactor] Avoid calling private ProcessMessage() function
    Calling this low-level function from tests is confusing, and also makes
    it harder to change the peer manager implementation.
    
    So juse use the pre-existing test helpers to achieve the same.
    faa4e5498a
  16. refactor: Make ProcessMessage private again
    It is not used in tests anymore.
    fa6fbf3fa8
  17. refactor: Pass CNode& to ProcessMessages and SendMessages
    The node is never nullptr.
    
    This can be reviewed with the git option:
    --word-diff-regex=.
    fa0bf0d81d
  18. refactor: Pass Peer& to ProcessMessage
    The peer is never nullptr.
    fa7cf4cd70
  19. refactor: Separate peer/maybe_peer in ProcessMessages and SendMessages
    Introducing two names to refer to the peer makes it possible to have one
    refer to a non-null reference in a later commit.
    fa13fc46a2
  20. scripted-diff: Use references when nullptr is not possible
    This allows to skip nullptr checks later in the code, both mentally and literally.
    
    This can be reviewed via the git option:
    --word-diff-regex=.
    
    -BEGIN VERIFY SCRIPT-
    
       sed --regexp-extended --in-place '
          /^bool PeerManagerImpl::SendMessages\(/,/^}$/   {
             s/auto& peer\{maybe_peer\}; .. alias cleaned up .*/Peer\& peer{*maybe_peer};/;
             s/peer->/peer./g;
             s/\*peer\>/peer/g;
    
             /CNode\* pto\{&node\}; .. alias removed .*/d;
             s/pto->/node./g;
             s/\*pto\>/node/g;
          }
       ' src/net_processing.cpp
    
       sed --regexp-extended --in-place '
          /^void PeerManagerImpl::ProcessMessage\(/,/^}$/   {
             /Peer\* peer\{&peer_alias_removed_in_later_commit};/d;
             s/peer_alias_removed_in_later_commit/peer/;
             s/peer->/peer./g;
             s/\*peer\>/peer/g;
          }
       ' src/net_processing.cpp
    
       sed --regexp-extended --in-place '
          /^bool PeerManagerImpl::ProcessMessages\(/,/^}$/   {
             s/auto& peer\{maybe_peer\}; .. alias cleaned up .*/Peer\& peer{*maybe_peer};/;
             s/peer->/peer./g;
             s/\*peer\>/peer/g;
    
             /CNode\* pfrom\{&node\}; .. alias removed .*/d;
             s/pfrom->/node./g;
             s/\*pfrom\>/node/g;
          }
       ' src/net_processing.cpp
    
    -END VERIFY SCRIPT-
    fa0468dab8
  21. move-only: Extract ProcessAddrs() helper
    This can be reviewed via the git options:
    --color-moved=dimmed-zebra  --color-moved-ws=ignore-all-space
    fa53143139
  22. refactor: Use NodeClock::time_point for m_addr_token_timestamp
    This refactor makes the field a bit more type-safe.
    faad5ffdfd
  23. refactor: Rename current_a_time to now_seconds
    This better reflects the meaning and use.
    fa4263a050
  24. doc: Fix LLM linter complaints
    Fix a typo and use a named arg for the Addrman::Add call to describe the
    purpose of the arg at the call site.
    fa651b93ae
  25. maflcko force-pushed on Dec 16, 2025
  26. DrahtBot removed the label Needs rebase on Dec 16, 2025
  27. DrahtBot added the label CI failed on Dec 16, 2025
  28. DrahtBot removed the label CI failed on Dec 16, 2025
  29. maflcko marked this as a draft on Dec 30, 2025
  30. maflcko commented at 4:34 pm on December 30, 2025: member
    Let’s review #34181 first (the first few commits), as they are likely useful more generally.
  31. DrahtBot added the label Needs rebase on Jan 12, 2026
  32. DrahtBot commented at 9:47 pm on January 12, 2026: contributor
    🐙 This pull request conflicts with the target branch and needs rebase.

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-01-22 03:13 UTC

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