Page MenuHomePhabricator

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

Authored by PiRK on Jun 13 2025, 08:29.

Details

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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable