clean up calls to NodeDB::GetIf to be cleaner and more concise

pull/1529/head
Jeff Becker 3 years ago
parent c8aba0af31
commit f24cdb305b
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -228,10 +228,10 @@ namespace llarp
std::optional<std::vector<RouterContact>>
Builder::GetHopsForBuild()
{
if (const auto maybe = m_router->nodedb()->GetIf([r = m_router](const auto& rc) -> bool {
return not r->routerProfiling().IsBadForPath(rc.pubkey);
});
maybe.has_value())
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))
{
return GetHopsAlignedToForBuild(maybe->pubkey);
}

@ -150,8 +150,7 @@ namespace llarp
return _rcLookupHandler.GetRandomWhitelistRouter(router);
}
if (const auto maybe = nodedb()->GetIf([](const auto&) -> bool { return true; }, true);
maybe.has_value())
if (const auto maybe = nodedb()->GetIf([](const auto&) -> bool { return true; }))
{
router = maybe->pubkey;
return true;

Loading…
Cancel
Save