[net, addrman] Remove external dependencies on CAddrInfo objects

CAddrInfo objects are an implementation detail of how AddrMan manages and adds
metadata to different records. Encapsulate this logic by updating Select &
SelectTriedCollision to return the additional info that the callers need.
This commit is contained in:
Amiti Uttarwar
2021-08-25 15:40:59 -07:00
parent 8af5b54f97
commit 7cba9d5618
6 changed files with 70 additions and 60 deletions

View File

@@ -171,13 +171,23 @@ public:
//! See if any to-be-evicted tried table entries have been tested and if so resolve the collisions.
void ResolveCollisions();
//! Randomly select an address in tried that another address is attempting to evict.
CAddrInfo SelectTriedCollision();
/**
* Randomly select an address in the tried table that another address is
* attempting to evict.
*
* @return CAddress The record for the selected tried peer.
* int64_t The last time we attempted to connect to that peer.
*/
std::pair<CAddress, int64_t> SelectTriedCollision();
/**
* Choose an address to connect to.
*
* @param[in] newOnly Whether to only select addresses from the new table.
* @return CAddress The record for the selected peer.
* int64_t The last time we attempted to connect to that peer.
*/
CAddrInfo Select(bool newOnly = false) const;
std::pair<CAddress, int64_t> Select(bool newOnly = false) const;
/**
* Return all or many randomly selected addresses, optionally by network.