ChainSafe / js-libp2p-noise

Noise libp2p handshake for js-libp2p
Other
37 stars 30 forks source link

fix: make handshake abortable #442

Closed achingbrain closed 1 month ago

achingbrain commented 2 months ago

To allow doing things like having a single AbortSignal that can be used as a timeout for incoming connection establishment, allow passing it as an option to the ConnectionEncrypter secureOutbound and secureInbound methods.

Previously we'd wrap the stream to be secured in an AbortableSource, however this has some serious performance implications and it's generally better to just use a signal to cancel an ongoing operation instead of racing every chunk that comes out of the source.

achingbrain commented 2 months ago

This PR changes the method signatures compatible with the as-yet unreleased libp2p@2.x.x similar to https://github.com/ChainSafe/js-libp2p-noise/pull/440

The corresponding changes to take advantage of this PR are in https://github.com/libp2p/js-libp2p/pull/2662 and that PR is blocked on release of this one.