@@ -150,88 +150,33 @@ class CAddrMan
150
150
151
151
explicit CAddrMan (std::vector<bool > asmap, bool deterministic, int32_t consistency_check_ratio);
152
152
153
- ~CAddrMan ()
154
- {
155
- nKey.SetNull ();
156
- }
153
+ ~CAddrMan ();
157
154
158
155
// ! Return the number of (unique) addresses in all tables.
159
- size_t size () const
160
- EXCLUSIVE_LOCKS_REQUIRED(!cs)
161
- {
162
- LOCK (cs); // TODO: Cache this in an atomic to avoid this overhead
163
- return vRandom.size ();
164
- }
156
+ size_t size () const EXCLUSIVE_LOCKS_REQUIRED(!cs);
165
157
166
158
// ! Add addresses to addrman's new table.
167
159
bool Add (const std::vector<CAddress> &vAddr, const CNetAddr& source, int64_t nTimePenalty = 0 )
168
- EXCLUSIVE_LOCKS_REQUIRED(!cs)
169
- {
170
- LOCK (cs);
171
- int nAdd = 0 ;
172
- Check ();
173
- for (std::vector<CAddress>::const_iterator it = vAddr.begin (); it != vAddr.end (); it++)
174
- nAdd += Add_ (*it, source, nTimePenalty) ? 1 : 0 ;
175
- Check ();
176
- if (nAdd) {
177
- LogPrint (BCLog::ADDRMAN, " Added %i addresses from %s: %i tried, %i new\n " , nAdd, source.ToString (), nTried, nNew);
178
- }
179
- return nAdd > 0 ;
180
- }
160
+ EXCLUSIVE_LOCKS_REQUIRED(!cs);
181
161
182
162
// ! Mark an entry as accessible.
183
163
void Good (const CService &addr, int64_t nTime = GetAdjustedTime())
184
- EXCLUSIVE_LOCKS_REQUIRED(!cs)
185
- {
186
- LOCK (cs);
187
- Check ();
188
- Good_ (addr, /* test_before_evict */ true , nTime);
189
- Check ();
190
- }
164
+ EXCLUSIVE_LOCKS_REQUIRED(!cs);
191
165
192
166
// ! Mark an entry as connection attempted to.
193
167
void Attempt (const CService &addr, bool fCountFailure , int64_t nTime = GetAdjustedTime())
194
- EXCLUSIVE_LOCKS_REQUIRED(!cs)
195
- {
196
- LOCK (cs);
197
- Check ();
198
- Attempt_ (addr, fCountFailure , nTime);
199
- Check ();
200
- }
168
+ EXCLUSIVE_LOCKS_REQUIRED(!cs);
201
169
202
170
// ! See if any to-be-evicted tried table entries have been tested and if so resolve the collisions.
203
- void ResolveCollisions ()
204
- EXCLUSIVE_LOCKS_REQUIRED(!cs)
205
- {
206
- LOCK (cs);
207
- Check ();
208
- ResolveCollisions_ ();
209
- Check ();
210
- }
171
+ void ResolveCollisions () EXCLUSIVE_LOCKS_REQUIRED(!cs);
211
172
212
173
// ! Randomly select an address in tried that another address is attempting to evict.
213
- CAddrInfo SelectTriedCollision ()
214
- EXCLUSIVE_LOCKS_REQUIRED(!cs)
215
- {
216
- LOCK (cs);
217
- Check ();
218
- const CAddrInfo ret = SelectTriedCollision_ ();
219
- Check ();
220
- return ret;
221
- }
174
+ CAddrInfo SelectTriedCollision () EXCLUSIVE_LOCKS_REQUIRED(!cs);
222
175
223
176
/* *
224
177
* Choose an address to connect to.
225
178
*/
226
- CAddrInfo Select (bool newOnly = false ) const
227
- EXCLUSIVE_LOCKS_REQUIRED(!cs)
228
- {
229
- LOCK (cs);
230
- Check ();
231
- const CAddrInfo addrRet = Select_ (newOnly);
232
- Check ();
233
- return addrRet;
234
- }
179
+ CAddrInfo Select (bool newOnly = false ) const EXCLUSIVE_LOCKS_REQUIRED(!cs);
235
180
236
181
/* *
237
182
* Return all or many randomly selected addresses, optionally by network.
@@ -241,36 +186,16 @@ class CAddrMan
241
186
* @param[in] network Select only addresses of this network (nullopt = all).
242
187
*/
243
188
std::vector<CAddress> GetAddr (size_t max_addresses, size_t max_pct, std::optional<Network> network) const
244
- EXCLUSIVE_LOCKS_REQUIRED(!cs)
245
- {
246
- LOCK (cs);
247
- Check ();
248
- std::vector<CAddress> vAddr;
249
- GetAddr_ (vAddr, max_addresses, max_pct, network);
250
- Check ();
251
- return vAddr;
252
- }
189
+ EXCLUSIVE_LOCKS_REQUIRED(!cs);
253
190
254
191
// ! Outer function for Connected_()
255
192
void Connected (const CService &addr, int64_t nTime = GetAdjustedTime())
256
- EXCLUSIVE_LOCKS_REQUIRED(!cs)
257
- {
258
- LOCK (cs);
259
- Check ();
260
- Connected_ (addr, nTime);
261
- Check ();
262
- }
193
+ EXCLUSIVE_LOCKS_REQUIRED(!cs);
263
194
264
195
void SetServices (const CService &addr, ServiceFlags nServices)
265
- EXCLUSIVE_LOCKS_REQUIRED(!cs)
266
- {
267
- LOCK (cs);
268
- Check ();
269
- SetServices_ (addr, nServices);
270
- Check ();
271
- }
196
+ EXCLUSIVE_LOCKS_REQUIRED(!cs);
272
197
273
- const std::vector<bool >& GetAsmap () const { return m_asmap; }
198
+ const std::vector<bool >& GetAsmap () const ;
274
199
275
200
private:
276
201
// ! A mutex to protect the inner data structures.
0 commit comments