HomePhabricator

refactor, net: End friendship of CNode, CConnman and ConnmanTestMsg

Description

refactor, net: End friendship of CNode, CConnman and ConnmanTestMsg

Summary:
We should define clear interfaces between CNode, CConnman and PeerManager. This PR makes a small step in that direction by ending the friendship of CNode, CConnman and ConnmanTestMsg. CNode's message processing queue is made private in the process and its mutex is turned into a non-recursive mutex.

make CNode::m_conn_type public

https://github.com/bitcoin/bitcoin/pull/27257/commits/ad44aa5c64d4ee5f31c867fda26350ab560575b7
https://github.com/bitcoin/bitcoin/pull/27324/commits/860402ef2ed728ef096dda4e65e77d566782209f

[net] Deduplicate marking received message for processing

[net] Encapsulate CNode message polling

[net] Make CNode msg process queue members private

Now that all access to the process queue members is handled by methods
of CNode we can make these members private.

[net] Make cs_vProcessMsg a non-recursive mutex

scripted-diff: [net] Rename CNode process queue members

-BEGIN VERIFY SCRIPT-
ren() { sed -i "s:\<$1\>:$2:g" $(git grep -l "\<$1\>" ./src ./test); }

ren cs_vProcessMsg m_msg_process_queue_mutex
ren vProcessMsg m_msg_process_queue
ren nProcessQueueSize m_msg_process_queue_size

-END VERIFY SCRIPT-

[net] Add CNode helper for send byte accounting

[net] Remove CNode friends

Both CConnman and ConnmanTestMsg no longer access private members of
CNode, we can therefore remove the friend relationship.

This is a backport of core#27257

Note the follow-up commit of core#27324 that reverts the GetConnectionType() getter

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D18247

Details

Provenance
PiRKAuthored on Jun 12 2025, 10:38
PiRKPushed on Jun 13 2025, 13:27
Reviewer
Restricted Project
Differential Revision
D18247: refactor, net: End friendship of CNode, CConnman and ConnmanTestMsg
Parents
rABC4c20e1471e68: net: remove misplaced and outdated comment
Branches
Unknown
Tags
Unknown