refactor: extract per-message helpers from ProcessMessage (move-only) #35502

pull w0xlt wants to merge 7 commits into bitcoin:master from w0xlt:refactor/extract-processmessage-helpers changing 1 files +485 −429
  1. w0xlt commented at 1:54 AM on June 10, 2026: contributor

    PeerManagerImpl::ProcessMessage() is a ~1000-line function handling every p2p message type inline, which makes it hard to navigate and review.

    This PR continues splitting it into per-message helper functions, following the pattern of the recently merged fa5ab0220e02377c3c855042ecdf1f5f950d0965 (ProcessPong()) and fa55723b8fbd4fd056dddac5b35daf2e86021422 (ProcessAddrs()),, as suggested by @maflcko #34588 (comment).

    Seven handlers are extracted, one commit each:

    • ProcessGetAddr()getaddr
    • ProcessGetDataMessage()getdata (named to avoid colliding with the existing ProcessGetData(), which services the request queue this handler fills)
    • ProcessGetBlocks()getblocks
    • ProcessGetHeaders()getheaders
    • ProcessInv()inv
    • ProcessSendTxRcncl()sendtxrcncl
    • ProcessTx()tx

    Each commit is a pure code move: the only new lines are the declaration (with thread-safety annotations), the function signature, and the one-line call site. Each call site is Helper(...); return;, so return statements inside the moved bodies keep identical semantics. No behavior change.

    Every commit can be reviewed with the git options: --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space

    Declarations and definitions are placed next to related existing helpers (e.g. ProcessGetDataMessage next to ProcessGetData, ProcessGetBlocks next to ProcessGetBlockData, ProcessGetAddr after ProcessAddrs).

  2. move-only: Extract ProcessGetAddr() helper
    This commit can be reviewed with the git options:
    --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
    2afa25ef8e
  3. move-only: Extract ProcessGetDataMessage() helper
    This commit can be reviewed with the git options:
    --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
    bc9154a4b2
  4. move-only: Extract ProcessGetBlocks() helper
    This commit can be reviewed with the git options:
    --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
    cb03c39cc5
  5. move-only: Extract ProcessGetHeaders() helper
    This commit can be reviewed with the git options:
    --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
    fb9216672c
  6. move-only: Extract ProcessInv() helper
    This commit can be reviewed with the git options:
    --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
    400857c65c
  7. move-only: Extract ProcessSendTxRcncl() helper
    This commit can be reviewed with the git options:
    --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
    19b613f4d7
  8. move-only: Extract ProcessTx() helper
    This commit can be reviewed with the git options:
    --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
    4fe745f27b
  9. DrahtBot added the label Refactoring on Jun 10, 2026
  10. DrahtBot commented at 1:54 AM on June 10, 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/35502.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK stickies-v, theStack, 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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  11. stickies-v commented at 10:49 AM on June 10, 2026: contributor

    Concept ACK. Pretty straightforward change that makes it easier to navigate net_processing and better encapsulates logic.

  12. theStack commented at 1:19 PM on June 10, 2026: contributor

    Concept ACK

    Fwiw this has been proposed at least once: #9608 (it seems to have failed more due to lack of review back then rather than on strong pushback, as far as I understand)

  13. pablomartin4btc commented at 3:06 PM on June 10, 2026: member

    Concept ACK.

    I'm in favour of these refactoring, while reviewing #34824 also identified another possible candidate SendMessages() which is in the same file.


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-06-10 23:50 UTC

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