add additional case check and documentation comments for pruning logic

pull/1171/head
Jeff Becker 4 years ago
parent b3f2c71617
commit bce5cd7b0f
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -725,11 +725,14 @@ namespace llarp
{
GossipRCIfNeeded(_rc);
}
const bool gotWhitelist = _rcLookupHandler.HaveReceivedWhitelist();
// remove RCs for nodes that are no longer allowed by network policy
nodedb()->RemoveIf([&](const RouterContact &rc) -> bool {
// don't pruge bootstrap nodes from nodedb
if(IsBootstrapNode(rc.pubkey))
return false;
// if for some reason we stored an RC that isn't a valid router
// purge this entry
if(not rc.IsPublicRouter())
return true;
// clients have a notion of a whilelist
@ -737,6 +740,14 @@ namespace llarp
// routers that are not whitelisted for first hops
if(not isSvcNode)
return false;
// if we have a whitelist enabled and we don't
// have the whitelist yet don't remove the entry
if(whitelistRouters and not gotWhitelist)
return false;
// if we have no whitelist enabled or we have
// the whitelist enabled and we got the whitelist
// check against the whitelist and remove if it's not
// in the whitelist OR if there is no whitelist don't remoev
return not _rcLookupHandler.RemoteIsAllowed(rc.pubkey);
});

Loading…
Cancel
Save