Fix: don't perform lookupCheck if not enough peers in routing table #970
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.
Currently, nodes will always perform a
lookupCheck
(FIND_PEER
request where receiver should reply with at least 1 peer record) before a peer is added to the routing table, and when refreshing the routing table.This check should be performed only if the routing table is well populated. Otherwise, it is tricky to bootstrap a new DHT network as the first peers start with an empty routing table, and are unable to provide peer to others when requested by the
lookupCheck
.The check will be skipped if the routing table contains less than
bucketSize
peers, which means that no bucket can be full. It implies that unresponsive peers making it to the routing table because the check was skipped will get evicted oncebucketSize
peers are present in the routing table, and they won't prevent well behaving peers from replacing them in the routing table.