mirror of https://github.com/oxen-io/lokinet
GetIf -> GetRandom
This commit is contained in:
parent
f24cdb305b
commit
1f1db29816
|
@ -86,7 +86,7 @@ namespace llarp
|
|||
|
||||
template <typename Filter>
|
||||
std::optional<RouterContact>
|
||||
GetIf(Filter visit) const
|
||||
GetRandom(Filter visit) const
|
||||
{
|
||||
util::NullLock lock{m_Access};
|
||||
const auto sz = m_Entries.size();
|
||||
|
|
|
@ -231,7 +231,7 @@ namespace llarp
|
|||
auto filter = [r = m_router](const auto& rc) -> bool {
|
||||
return not r->routerProfiling().IsBadForPath(rc.pubkey);
|
||||
};
|
||||
if (const auto maybe = m_router->nodedb()->GetIf(filter))
|
||||
if (const auto maybe = m_router->nodedb()->GetRandom(filter))
|
||||
{
|
||||
return GetHopsAlignedToForBuild(maybe->pubkey);
|
||||
}
|
||||
|
@ -315,8 +315,8 @@ namespace llarp
|
|||
}
|
||||
else
|
||||
{
|
||||
const auto maybe =
|
||||
m_router->nodedb()->GetIf([&hops, r = m_router, endpoint](const auto& rc) -> bool {
|
||||
const auto maybe = m_router->nodedb()->GetRandom(
|
||||
[&hops, r = m_router, endpoint](const auto& rc) -> bool {
|
||||
if (r->routerProfiling().IsBadForPath(rc.pubkey))
|
||||
return false;
|
||||
for (const auto& hop : hops)
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace llarp
|
|||
auto filter = [exclude](const auto& rc) -> bool { return exclude.count(rc.pubkey) == 0; };
|
||||
|
||||
RouterContact other;
|
||||
if (const auto maybe = _nodedb->GetIf(filter); maybe.has_value())
|
||||
if (const auto maybe = _nodedb->GetRandom(filter))
|
||||
{
|
||||
other = *maybe;
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ namespace llarp
|
|||
return _rcLookupHandler.GetRandomWhitelistRouter(router);
|
||||
}
|
||||
|
||||
if (const auto maybe = nodedb()->GetIf([](const auto&) -> bool { return true; }))
|
||||
if (const auto maybe = nodedb()->GetRandom([](const auto&) -> bool { return true; }))
|
||||
{
|
||||
router = maybe->pubkey;
|
||||
return true;
|
||||
|
|
|
@ -652,7 +652,7 @@ namespace llarp
|
|||
{
|
||||
std::unordered_set<RouterID> exclude;
|
||||
ForEachPath([&exclude](auto path) { exclude.insert(path->Endpoint()); });
|
||||
const auto maybe = m_router->nodedb()->GetIf(
|
||||
const auto maybe = m_router->nodedb()->GetRandom(
|
||||
[exclude](const auto& rc) -> bool { return exclude.count(rc.pubkey) == 0; });
|
||||
if (not maybe.has_value())
|
||||
return std::nullopt;
|
||||
|
@ -698,7 +698,7 @@ namespace llarp
|
|||
else
|
||||
return std::nullopt;
|
||||
}
|
||||
else if (const auto maybe = m_router->nodedb()->GetIf(filter); maybe.has_value())
|
||||
else if (const auto maybe = m_router->nodedb()->GetRandom(filter))
|
||||
{
|
||||
hops.emplace_back(*maybe);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue