Skip to content

Commit 29727c2

Browse files
committed
[doc] Update comments
Maintain comments on the external interfaces rather than on the internal functions that implement them.
1 parent 14f9e00 commit 29727c2

File tree

3 files changed

+16
-30
lines changed

3 files changed

+16
-30
lines changed

src/addrman.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
static constexpr uint32_t ADDRMAN_TRIED_BUCKETS_PER_GROUP{8};
2424
/** Over how many buckets entries with new addresses originating from a single group are spread */
2525
static constexpr uint32_t ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP{64};
26-
/** Maximum number of times an address can be added to the new table */
26+
/** Maximum number of times an address can occur in the new table */
2727
static constexpr int32_t ADDRMAN_NEW_BUCKETS_PER_ADDRESS{8};
2828
/** How old addresses can maximally be */
2929
static constexpr int64_t ADDRMAN_HORIZON_DAYS{30};

src/addrman.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class CAddrMan
7474
//! Add addresses to addrman's new table.
7575
bool Add(const std::vector<CAddress> &vAddr, const CNetAddr& source, int64_t nTimePenalty = 0);
7676

77-
//! Mark an entry as accessible.
77+
//! Mark an entry as accessible, possibly moving it from "new" to "tried".
7878
void Good(const CService &addr, int64_t nTime = GetAdjustedTime());
7979

8080
//! Mark an entry as connection attempted to.
@@ -107,12 +107,25 @@ class CAddrMan
107107
* @param[in] max_addresses Maximum number of addresses to return (0 = all).
108108
* @param[in] max_pct Maximum percentage of addresses to return (0 = all).
109109
* @param[in] network Select only addresses of this network (nullopt = all).
110+
*
111+
* @return A vector of randomly selected addresses from vRandom.
110112
*/
111113
std::vector<CAddress> GetAddr(size_t max_addresses, size_t max_pct, std::optional<Network> network) const;
112114

113-
//! Outer function for Connected_()
115+
/** We have successfully connected to this peer. Calling this function
116+
* updates the CAddress's nTime, which is used in our IsTerrible()
117+
* decisions and gossiped to peers. Callers should be careful that updating
118+
* this information doesn't leak topology information to network spies.
119+
*
120+
* net_processing calls this function when it *disconnects* from a peer to
121+
* not leak information about currently connected peers.
122+
*
123+
* @param[in] addr The address of the peer we were connected to
124+
* @param[in] nTime The time that we were last connected to this peer
125+
*/
114126
void Connected(const CService &addr, int64_t nTime = GetAdjustedTime());
115127

128+
//! Update an entry's service bits.
116129
void SetServices(const CService &addr, ServiceFlags nServices);
117130

118131
const std::vector<bool>& GetAsmap() const;

src/addrman_impl.h

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -227,49 +227,22 @@ class AddrManImpl
227227
//! Move an entry from the "new" table(s) to the "tried" table
228228
void MakeTried(CAddrInfo& info, int nId) EXCLUSIVE_LOCKS_REQUIRED(cs);
229229

230-
//! Mark an entry "good", possibly moving it from "new" to "tried".
231230
void Good_(const CService &addr, bool test_before_evict, int64_t time) EXCLUSIVE_LOCKS_REQUIRED(cs);
232231

233-
//! Add an entry to the "new" table.
234232
bool Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty) EXCLUSIVE_LOCKS_REQUIRED(cs);
235233

236-
//! Mark an entry as attempted to connect.
237234
void Attempt_(const CService &addr, bool fCountFailure, int64_t nTime) EXCLUSIVE_LOCKS_REQUIRED(cs);
238235

239-
//! Select an address to connect to, if newOnly is set to true, only the new table is selected from.
240236
std::pair<CAddress, int64_t> Select_(bool newOnly) const EXCLUSIVE_LOCKS_REQUIRED(cs);
241237

242-
/**
243-
* Return all or many randomly selected addresses, optionally by network.
244-
*
245-
* @param[in] max_addresses Maximum number of addresses to return (0 = all).
246-
* @param[in] max_pct Maximum percentage of addresses to return (0 = all).
247-
* @param[in] network Select only addresses of this network (nullopt = all).
248-
*
249-
* @returns A vector of randomly selected addresses from vRandom.
250-
*/
251238
std::vector<CAddress> GetAddr_(size_t max_addresses, size_t max_pct, std::optional<Network> network) const EXCLUSIVE_LOCKS_REQUIRED(cs);
252239

253-
/** We have successfully connected to this peer. Calling this function
254-
* updates the CAddress's nTime, which is used in our IsTerrible()
255-
* decisions and gossiped to peers. Callers should be careful that updating
256-
* this information doesn't leak topology information to network spies.
257-
*
258-
* net_processing calls this function when it *disconnects* from a peer to
259-
* not leak information about currently connected peers.
260-
*
261-
* @param[in] addr The address of the peer we were connected to
262-
* @param[in] nTime The time that we were last connected to this peer
263-
*/
264240
void Connected_(const CService& addr, int64_t nTime) EXCLUSIVE_LOCKS_REQUIRED(cs);
265241

266-
//! Update an entry's service bits.
267242
void SetServices_(const CService &addr, ServiceFlags nServices) EXCLUSIVE_LOCKS_REQUIRED(cs);
268243

269-
//! See if any to-be-evicted tried table entries have been tested and if so resolve the collisions.
270244
void ResolveCollisions_() EXCLUSIVE_LOCKS_REQUIRED(cs);
271245

272-
//! Return a random to-be-evicted tried table address.
273246
std::pair<CAddress, int64_t> SelectTriedCollision_() EXCLUSIVE_LOCKS_REQUIRED(cs);
274247

275248
//! Consistency check, taking into account m_consistency_check_ratio. Will std::abort if an inconsistency is detected.

0 commit comments

Comments
 (0)