-
Notifications
You must be signed in to change notification settings - Fork 37
feat: add basic dial queue to avoid many connections to peer #310
Conversation
BREAKING CHANGE: This adds a very basic dial queue peer peer. This will prevent multiple, simultaneous dial requests to the same peer from creating multiple connections. The requests will be queued per peer, and will leverage the same connection when possible. The breaking change here is that `.dial`, will no longer return a connection. js-libp2p, circuit relay, and kad-dht, which use `.dial` were not using the returned connection. So while this is a breaking change it should not break the existing libp2p stack. If custom applications are leveraging the returned connection, they will need to convert to only using the connection returned via the callback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good! Awesome work Jacob!
17e356a
to
988d212
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good 👍 - most of my comments are around code organisation so pretty much all suggestions really.
@@ -366,8 +379,6 @@ class ConnectionFSM extends BaseConnection { | |||
const conn = observeConnection(null, key, _conn, this.switch.observer) | |||
|
|||
this.muxer = this.switch.muxers[key].dialer(conn) | |||
// this.switch.muxedConns[this.theirB58Id] = this | |||
this.switch.connection.add(this) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this no longer added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now controlled by the dialer queue.
Aside from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
See the commit details, added here for ease:
Required by libp2p/js-libp2p#336