aboutsummaryrefslogtreecommitdiff
path: root/src/addrman.cpp
diff options
context:
space:
mode:
authorAmiti Uttarwar <amiti@uttarwar.org>2021-09-22 15:47:49 -0600
committerAmiti Uttarwar <amiti@uttarwar.org>2021-09-28 19:02:34 -0400
commit14f9e000d05f82b364d5a142cafc70b10406b660 (patch)
tree1dafd2518b738523c4e37f3650689475ccac85e2 /src/addrman.cpp
parent40acd6fc9a8098fed85abf4fb727a5f0dff8a2ff (diff)
downloadbitcoin-14f9e000d05f82b364d5a142cafc70b10406b660.tar.xz
[refactor] Update GetAddr_() function signature
Update so the internal function signature matches the external one, as is the case for the other addrman functions.
Diffstat (limited to 'src/addrman.cpp')
-rw-r--r--src/addrman.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/addrman.cpp b/src/addrman.cpp
index 324bab7292..40e087f5fb 100644
--- a/src/addrman.cpp
+++ b/src/addrman.cpp
@@ -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);
@@ -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
const int64_t now{GetAdjustedTime()};
+ std::vector<CAddress> addresses;
for (unsigned int n = 0; n < vRandom.size(); n++) {
- if (vAddr.size() >= nNodes)
+ if (addresses.size() >= nNodes)
break;
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
if (ai.IsTerrible(now)) continue;
- vAddr.push_back(ai);
+ addresses.push_back(ai);
}
+
+ return addresses;
}
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);
Check();
- std::vector<CAddress> vAddr;
- GetAddr_(vAddr, max_addresses, max_pct, network);
+ const auto addresses = GetAddr_(max_addresses, max_pct, network);
Check();
- return vAddr;
+ return addresses;
}
void AddrManImpl::Connected(const CService &addr, int64_t nTime)