mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
[addrman] Specify max addresses and pct when calling GetAddresses()
CAddrMan.GetAddr() would previously limit the number and percentage of addresses returned (to ADDRMAN_GETADDR_MAX (1000) and ADDRMAN_GETADDR_MAX_PCT (23) respectively). Instead, make it the callers responsibility to specify the maximum addresses and percentage they want returned. For net_processing, the maximums are MAX_ADDR_TO_SEND (1000) and MAX_PCT_ADDR_TO_SEND (23). For rpc/net, the maximum is specified by the client.
This commit is contained in:
parent
3c93623be2
commit
f26502e9fc
8 changed files with 35 additions and 38 deletions
|
|
@ -479,11 +479,15 @@ int CAddrMan::Check_()
|
|||
}
|
||||
#endif
|
||||
|
||||
void CAddrMan::GetAddr_(std::vector<CAddress>& vAddr)
|
||||
void CAddrMan::GetAddr_(std::vector<CAddress>& vAddr, size_t max_addresses, size_t max_pct)
|
||||
{
|
||||
unsigned int nNodes = ADDRMAN_GETADDR_MAX_PCT * vRandom.size() / 100;
|
||||
if (nNodes > ADDRMAN_GETADDR_MAX)
|
||||
nNodes = ADDRMAN_GETADDR_MAX;
|
||||
size_t nNodes = vRandom.size();
|
||||
if (max_pct != 0) {
|
||||
nNodes = max_pct * nNodes / 100;
|
||||
}
|
||||
if (max_addresses != 0) {
|
||||
nNodes = std::min(nNodes, max_addresses);
|
||||
}
|
||||
|
||||
// gather a list of random nodes, skipping those of low quality
|
||||
for (unsigned int n = 0; n < vRandom.size(); n++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue