Commit 22526ae
committed
Merge #7248: refactor: simplify CoinJoin class hierarchy
eb2142d fix: added missing thread annotation for CJWalletManagerImpl (Konstantin Akimov)
40cd08d refactor: rename CCoinJoinBaseManager to CoinJoinQueueManager and make it non-virtual (Konstantin Akimov)
6fae09a refactor: remove inheritance from CCoinJoinBaseManager in src/test/coinjoin_basemanager_tests.cpp (Konstantin Akimov)
a0f39f2 refactor: removed CCoinJoinBaseManager from inheritance of CCoinJoinServer and make it a member (Konstantin Akimov)
72229ce refactor: inline class CCoinJoinClientQueueManager to CJWalletManagerImpl (Konstantin Akimov)
3b1c2da refactor: inline the middleman class CoinJoinWalletManager to CJWalletManagerImpl (Konstantin Akimov)
e2d8247 refactor: pass directly reference to CCoinJoinClientManager& instead unique_ptr inside ForEachCJClientMan (Konstantin Akimov)
689b4ec refactor: remove passing pointer to unique_ptr to more clear sequence of object initializtion in CJ (Konstantin Akimov)
Pull request description:
## Issue being fixed or feature implemented
Current coinjoin subsystem have multiple classes that inherits from each other but some of them doesn't provide any real abstraction level yet complicate architecture.
CJWalletManagerImpl, CCoinJoinClientManager, and CCoinJoinClientQueueManager are 2 separate pieces of implementation of CJWalletManager while CJWalletManagerImpl is already private and could keep all implementation inside.
## What was done?
This PR simplify CJ architecture by removing boiler code and unneeded abstraction levels to make code easier to support, read and improve.
The changes for this PR has been spotted and half-done during #7234 but it's not a direct dependency of final solution, so far as it was possible to fully cut CJ from dash-chainstate implementation.
- replaces all references to unique_ptr to just a reference or just unique_ptr to more clear sequence of object initialization in CJ and ownership
- inline the middleman class CoinJoinWalletManager to CJWalletManagerImpl which is already private and hidden
- remove class CCoinJoinClientQueueManager; logic inlined into CJWalletManagerImpl
- remove interface CoinJoinQueueNotify - que notification no longer needed as a separate abstraction
- replaced inheritance of CCoinJoinServer : public CCoinJoinBaseManager to composition (m_queueman member)
- remove inheritance of regression tests from CCoinJoinBaseManager
- rename CCoinJoinBaseManager to CoinJoinQueueManager and make it non-virtual
## CoinJoin Class Diagram — Before vs After [by claude]
BEFORE
CCoinJoinBaseManager CoinJoinQueueNotify
(virtual ctor/dtor) (interface)
- vecCoinJoinQueue - OnQueueUpdate() [pure]
- cs_vecqueue
▲ ▲
│ inherits │ implements
├─────────────────┐ │
CCoinJoinClientQueueManager CCoinJoinClientManager
(owned by CJWalletManagerImpl) (map entry per wallet)
│
│ inherits
│
CCoinJoinServer ──also inherits──▶ CCoinJoinBaseSession
▲
│ inherits
CCoinJoinClientSession
CJWalletManager (abstract)
└── CJWalletManagerImpl
├── unique_ptr<CCoinJoinClientQueueManager> m_basequeueman
└── map<wallet* → CCoinJoinClientManager>
---
AFTER
CoinJoinQueueManager ← renamed (no C prefix), no virtual ctor/dtor
- vecCoinJoinQueue no longer a base class at all
- cs_vecqueue
+ TryHasQueueFromMasternode() new TRY_LOCK helpers
+ TryCheckDuplicate()
+ TryAddQueue()
CCoinJoinServer ──inherits──▶ CCoinJoinBaseSession
- m_queueman: CoinJoinQueueManager ← OWNED by value (composition)
▲
│ inherits
CCoinJoinClientSession
CJWalletManager (abstract)
└── CJWalletManagerImpl
├── unique_ptr<CoinJoinQueueManager> m_queueman ← nullptr if !relay_txes
└── map<wallet* → CCoinJoinClientManager>
│
│ CCoinJoinClientManager
│ - m_queueman: CoinJoinQueueManager* ← non-owning ptr
│ (points into CJWalletManagerImpl::m_queueman)
## How Has This Been Tested?
Run unit & functional tests.
## Breaking Changes
N/A
## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone
ACKs for top commit:
UdjinM6:
utACK eb2142d
Tree-SHA512: 03a648885d86c6e251296b3315ddf2ffb0ab3839526cf10a52bb36f53dc7ff1888bc45f69bbdcddd8a32bd940955cf6e8487e84062d0dde9daa32317721eeb5a11 files changed
Lines changed: 342 additions & 438 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
126 | 125 | | |
127 | 126 | | |
128 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | 43 | | |
156 | 44 | | |
157 | 45 | | |
158 | | - | |
| 46 | + | |
159 | 47 | | |
160 | 48 | | |
161 | 49 | | |
| |||
192 | 80 | | |
193 | 81 | | |
194 | 82 | | |
195 | | - | |
196 | | - | |
| 83 | + | |
197 | 84 | | |
198 | 85 | | |
199 | 86 | | |
200 | 87 | | |
201 | 88 | | |
202 | | - | |
203 | | - | |
| 89 | + | |
204 | 90 | | |
205 | 91 | | |
206 | 92 | | |
| |||
1007 | 893 | | |
1008 | 894 | | |
1009 | 895 | | |
1010 | | - | |
| 896 | + | |
1011 | 897 | | |
1012 | 898 | | |
1013 | 899 | | |
| |||
1075 | 961 | | |
1076 | 962 | | |
1077 | 963 | | |
1078 | | - | |
1079 | 964 | | |
1080 | 965 | | |
1081 | 966 | | |
1082 | 967 | | |
1083 | 968 | | |
1084 | 969 | | |
1085 | | - | |
| 970 | + | |
1086 | 971 | | |
1087 | 972 | | |
1088 | 973 | | |
| |||
1288 | 1173 | | |
1289 | 1174 | | |
1290 | 1175 | | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
1291 | 1181 | | |
1292 | 1182 | | |
1293 | 1183 | | |
| |||
1893 | 1783 | | |
1894 | 1784 | | |
1895 | 1785 | | |
1896 | | - | |
1897 | | - | |
1898 | | - | |
1899 | | - | |
1900 | | - | |
1901 | | - | |
1902 | | - | |
1903 | | - | |
1904 | | - | |
1905 | | - | |
1906 | | - | |
1907 | | - | |
1908 | | - | |
1909 | | - | |
1910 | | - | |
1911 | | - | |
1912 | | - | |
1913 | | - | |
1914 | | - | |
1915 | | - | |
1916 | | - | |
1917 | | - | |
1918 | | - | |
1919 | | - | |
1920 | | - | |
1921 | | - | |
1922 | | - | |
1923 | | - | |
1924 | | - | |
1925 | | - | |
1926 | | - | |
1927 | | - | |
1928 | | - | |
1929 | | - | |
1930 | | - | |
1931 | | - | |
1932 | | - | |
1933 | | - | |
1934 | | - | |
1935 | | - | |
1936 | | - | |
1937 | | - | |
1938 | | - | |
1939 | | - | |
1940 | | - | |
1941 | | - | |
1942 | | - | |
1943 | | - | |
1944 | | - | |
1945 | | - | |
1946 | | - | |
1947 | | - | |
1948 | | - | |
1949 | | - | |
1950 | | - | |
1951 | | - | |
0 commit comments