p2p: allow CAddrMan::GetAddr() by network, add doxygen

This commit is contained in:
Jon Atack
2021-05-02 19:03:49 +02:00
parent c38981e748
commit a49f3ddbba
5 changed files with 24 additions and 13 deletions

View File

@@ -287,7 +287,7 @@ protected:
* @param[in] max_pct Maximum percentage of addresses to return (0 = all).
* @param[in] network Select only addresses of this network (nullopt = all).
*/
void GetAddr_(std::vector<CAddress>& vAddr, size_t max_addresses, size_t max_pct, std::optional<Network> network = std::nullopt) EXCLUSIVE_LOCKS_REQUIRED(cs);
void GetAddr_(std::vector<CAddress>& vAddr, size_t max_addresses, size_t max_pct, std::optional<Network> network) EXCLUSIVE_LOCKS_REQUIRED(cs);
/** We have successfully connected to this peer. Calling this function
* updates the CAddress's nTime, which is used in our IsTerrible()
@@ -723,14 +723,20 @@ public:
return addrRet;
}
//! Return a bunch of addresses, selected at random.
std::vector<CAddress> GetAddr(size_t max_addresses, size_t max_pct)
/**
* Return all or many randomly selected addresses, optionally by network.
*
* @param[in] max_addresses Maximum number of addresses to return (0 = all).
* @param[in] max_pct Maximum percentage of addresses to return (0 = all).
* @param[in] network Select only addresses of this network (nullopt = all).
*/
std::vector<CAddress> GetAddr(size_t max_addresses, size_t max_pct, std::optional<Network> network)
{
Check();
std::vector<CAddress> vAddr;
{
LOCK(cs);
GetAddr_(vAddr, max_addresses, max_pct);
GetAddr_(vAddr, max_addresses, max_pct, network);
}
Check();
return vAddr;