Repository navigation
Conversation
Define four new sub-structs in the anonymous namespace before Peer: - PeerAddrRelay: address gossip fields and mutex - PeerHeadersSyncState: headers sync fields and mutex - PeerBlockAnnouncement: block inv relay fields and mutex - PeerLatency: ping/pong atomics (no mutex needed) Add four member objects to Peer (m_addr_relay, m_headers_sync_state, m_block_announcement, m_latency). No call sites change yet -- old fields still exist alongside the new sub-struct members. This prepares for subsequent scripted-diff commits that will move fields from Peer into the corresponding sub-structs.
Move-only rename: all address relay fields (m_addrs_to_send, m_addr_known, m_addr_relay_enabled, m_getaddr_sent, m_getaddr_recvd, m_wants_addrv2, m_addr_token_bucket, m_addr_token_timestamp, m_addr_rate_limited, m_addr_processed, m_next_addr_send, m_next_local_addr_send, m_addr_send_times_mutex) are moved from Peer into Peer::m_addr_relay (PeerAddrRelay sub-struct). Also moves m_inv_triggered_getheaders_before_sync into Peer::m_headers_sync_state since it was adjacent to the removed addr fields and belongs to headers sync state. Delete original fields from Peer, update all ~50 call sites.
Move-only rename: all headers sync fields (m_headers_sync_mutex, m_headers_sync, m_sent_sendheaders, m_headers_sync_timeout, m_prefers_headers, m_last_getheaders_timestamp) are moved from Peer into Peer::m_headers_sync_state (PeerHeadersSyncState sub-struct). Update EXCLUSIVE_LOCKS_REQUIRED annotations on IsContinuationOfLowWorkHeadersSync() and TryLowWorkHeadersSync() to reference peer.m_headers_sync_state.m_headers_sync_mutex. Delete original fields from Peer, update all ~40 call sites.
Move-only rename: all block announcement fields (m_block_inv_mutex, m_blocks_for_inv_relay, m_blocks_for_headers_relay, m_continuation_block) are moved from Peer into Peer::m_block_announcement (PeerBlockAnnouncement sub-struct). Delete original fields from Peer, update all ~25 call sites.
Move-only rename: all latency measurement fields (m_ping_nonce_sent, m_ping_start, m_ping_queued) are moved from Peer into Peer::m_latency (PeerLatency sub-struct). All fields are atomic so no mutex is needed for the sub-struct. Delete original fields from Peer, update all ~25 call sites.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34588. ReviewsSee the guideline for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
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. LLM Linter (✨ experimental)Possible typos and grammar issues:
Possible places where named args for integral literals may be used (e.g.
2026-02-14 02:47:54 |
|
🐙 This pull request conflicts with the target branch and needs rebase. |
|
⌛ There hasn't been much activity lately and the patch still needs rebase. What is the status here?
|
Is this true? IIUC the sections are nicely separated with newlines and annotated with Also, I am not sure about the current state of this pull. E.g. If this change was done, it would be better to at least not make this worse and shorten the names. E.g. Though, I think generally a lower hanging fruit would be to split the massive single process function into smaller ones. Similar to commit fa5ab02 |
|
Thanks for the feedback. Closing this in favor of #35502, which is more aligned to your suggestion. |
The
Peerstruct innet_processing.cpphas ~40 fields protected by 6 different mutexes, mixing address relay, headers sync, block announcements, ping/pong, transaction relay, and misbehavior state into one flat struct.This makes it hard to see which fields belong together and which mutex protects what.
This PR groups related fields into four sub-structs, each owning its mutex where applicable:
PeerAddrRelaym_addr_send_times_mutexPeerHeadersSyncStatem_headers_sync_mutexPeerBlockAnnouncementm_block_inv_mutexPeerLatencyAccess changes from flat (
peer.m_addrs_to_send) to qualified (peer.m_addr_relay.m_addrs_to_send). No locking semantics, runtime behavior, or public interfaces change.The first commit defines the four structs and adds them as members of
Peer. The remaining four commits each move one group of fields and update all call sites.