mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
[refactor] Update GetAddr_() function signature
Update so the internal function signature matches the external one, as is the case for the other addrman functions.
This commit is contained in:
parent
40acd6fc9a
commit
14f9e000d0
2 changed files with 11 additions and 8 deletions
|
@ -745,7 +745,7 @@ std::pair<CAddress, int64_t> AddrManImpl::Select_(bool newOnly) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddrManImpl::GetAddr_(std::vector<CAddress>& vAddr, size_t max_addresses, size_t max_pct, std::optional<Network> network) const
|
std::vector<CAddress> AddrManImpl::GetAddr_(size_t max_addresses, size_t max_pct, std::optional<Network> network) const
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs);
|
AssertLockHeld(cs);
|
||||||
|
|
||||||
|
@ -759,8 +759,9 @@ void AddrManImpl::GetAddr_(std::vector<CAddress>& vAddr, size_t max_addresses, s
|
||||||
|
|
||||||
// gather a list of random nodes, skipping those of low quality
|
// gather a list of random nodes, skipping those of low quality
|
||||||
const int64_t now{GetAdjustedTime()};
|
const int64_t now{GetAdjustedTime()};
|
||||||
|
std::vector<CAddress> addresses;
|
||||||
for (unsigned int n = 0; n < vRandom.size(); n++) {
|
for (unsigned int n = 0; n < vRandom.size(); n++) {
|
||||||
if (vAddr.size() >= nNodes)
|
if (addresses.size() >= nNodes)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
int nRndPos = insecure_rand.randrange(vRandom.size() - n) + n;
|
int nRndPos = insecure_rand.randrange(vRandom.size() - n) + n;
|
||||||
|
@ -776,8 +777,10 @@ void AddrManImpl::GetAddr_(std::vector<CAddress>& vAddr, size_t max_addresses, s
|
||||||
// Filter for quality
|
// Filter for quality
|
||||||
if (ai.IsTerrible(now)) continue;
|
if (ai.IsTerrible(now)) continue;
|
||||||
|
|
||||||
vAddr.push_back(ai);
|
addresses.push_back(ai);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return addresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddrManImpl::Connected_(const CService& addr, int64_t nTime)
|
void AddrManImpl::Connected_(const CService& addr, int64_t nTime)
|
||||||
|
@ -1080,10 +1083,9 @@ std::vector<CAddress> AddrManImpl::GetAddr(size_t max_addresses, size_t max_pct,
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
Check();
|
Check();
|
||||||
std::vector<CAddress> vAddr;
|
const auto addresses = GetAddr_(max_addresses, max_pct, network);
|
||||||
GetAddr_(vAddr, max_addresses, max_pct, network);
|
|
||||||
Check();
|
Check();
|
||||||
return vAddr;
|
return addresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddrManImpl::Connected(const CService &addr, int64_t nTime)
|
void AddrManImpl::Connected(const CService &addr, int64_t nTime)
|
||||||
|
|
|
@ -242,12 +242,13 @@ private:
|
||||||
/**
|
/**
|
||||||
* Return all or many randomly selected addresses, optionally by network.
|
* Return all or many randomly selected addresses, optionally by network.
|
||||||
*
|
*
|
||||||
* @param[out] vAddr Vector of randomly selected addresses from vRandom.
|
|
||||||
* @param[in] max_addresses Maximum number of addresses to return (0 = all).
|
* @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] max_pct Maximum percentage of addresses to return (0 = all).
|
||||||
* @param[in] network Select only addresses of this network (nullopt = all).
|
* @param[in] network Select only addresses of this network (nullopt = all).
|
||||||
|
*
|
||||||
|
* @returns A vector of randomly selected addresses from vRandom.
|
||||||
*/
|
*/
|
||||||
void GetAddr_(std::vector<CAddress>& vAddr, size_t max_addresses, size_t max_pct, std::optional<Network> network) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
std::vector<CAddress> GetAddr_(size_t max_addresses, size_t max_pct, std::optional<Network> network) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
|
|
||||||
/** We have successfully connected to this peer. Calling this function
|
/** We have successfully connected to this peer. Calling this function
|
||||||
* updates the CAddress's nTime, which is used in our IsTerrible()
|
* updates the CAddress's nTime, which is used in our IsTerrible()
|
||||||
|
|
Loading…
Add table
Reference in a new issue