Conversation
fullrt builds its entire routing table from what the crawler reports, and
filters every reported peer through kaddht.PublicRoutingTableFilter before
keeping it. That filter starts by requiring an open connection to the peer:
conns := d.Host().Network().ConnsToPeer(p)
if len(conns) == 0 {
return false
}
which holds for DefaultCrawler, because it has just dialled the peer and the
connection is still open when handleSuccess runs. It cannot hold for a crawler
that reports peers it did not dial. The motivating case is a crawler that
replays a routing table persisted from a previous run, so a restart is warm in
seconds rather than after a full crawl: it dials nothing by design, so every
peer it reports is dropped, the table stays empty, Ready() never becomes true,
and the next refresh crawl - which is seeded from the peers the last one found -
degrades to a cold crawl from the bootstrap peers.
No existing option reaches this, so add one. WithRouteTableFilter takes the
existing kaddht.RouteTableFilterFunc and defaults to
kaddht.PublicRoutingTableFilter, so behaviour is unchanged unless a caller asks
for something else. The filter is handed the *FullRT, which is what the default
already expects, so a caller can delegate to PublicRoutingTableFilter and widen
it rather than reimplement the public and relay checks it still wants.
PublicRoutingTableFilter itself is untouched. The standard DHT's routing table
uses it too, and that is where the connection requirement earns its keep.
Tests cover the default still dropping a reported peer with no connection (the
regression guard), a supplied filter admitting them and making Ready() true, a
supplied filter rejecting everything, and the option rejecting nil.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeQZdq8YRVNZqwcFvJ9hrj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Opened against the wrong repository in error and closed. Please disregard.