Merged
Conversation
Contributor
Drache93
commented
Feb 20, 2026
- Add support for encoding closest nodes in key
- flip order of providedNodes
Contributor
Author
|
Have moved to using |
lejeunerenard
requested changes
Mar 17, 2026
lejeunerenard
approved these changes
Apr 1, 2026
* Use closestNodes to connect in parallel to findPeer query Given `relayAddresses` (referred to as `closestNodes` in `dht-rpc`) are passed when connecting, these nodes could be used to connect through immediately while the normal `FIND_PEER` query is run. The closestNodes are likely candidates for connecting to a specific peer so attempting connection can speed up connection by skipping querying the DHT. To accommodate the extra connection, the total connections allowed is increased by 1 when closestNodes are passed. If a closestNode is returned as part of the findPeer query, then connection is skipped assuming that the preConnect parallel approach will establish the connection. * Add closestNode address to remoteRelayAddresses when attempting In the same way that connectThroughNode may work for a node returned via a `FIND_PEER` query, closestNodes attempted as part of preconnect should also be tracked for caching. * Add closestNode address to remoteRelayAddresses when attempting In the same way that connectThroughNode may work for a node returned via a `FIND_PEER` query, closestNodes attempted as part of preconnect should also be tracked for caching. * Check that `closestNodes` is set before skipping node in `FIND_PEER` `preConnect` can be `true` while `closestNodes` is `null` when the `closestNodes` were set initially but then cleared when the query makes a second attempt. * Filter out double `open` events in server side pool test This test previously wasn't likely to emit two `open` events, but since the pre-connect feature was added, if the client has the servers `id` in it's cache and populates the `closestNodes` with it, it will immediately connect to the server via the relay node simultaneously. This allows the encrypted stream to `open` twice instead of the normal 1 time because the connection to the relay has opened but the connection from the relay to the server will error when a duplicate connection is detected. * Split out logic to detect if `FIND_PEER` node is an existing `closestNode` Moved to a function with a simple for loop instead of using `.find()`. * Use `preConnect` bool to set number of semaphore waits Without this check, 3 query nodes would attempt connecting at once if `closestNodes` is an empty array. Pre-connnect wouldn't run so they should be the same. * Rename `closestNodes` to `relayAddresses` in `findAndConnect()` Often `closestNodes` & `relayAddresses` are the same, but they are distinct. `closestNodes` are DHT nodes that are closest (via XOR metric) to the target. `relayAddresses` are nodes that will serve as the relay node for doing the handshake with a given peer.
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.