js-libp2p icon indicating copy to clipboard operation
js-libp2p copied to clipboard

fix!: make connection securing abortable

Open achingbrain opened this issue 1 year ago • 0 comments

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.

BREAKING CHANGE: the final argument to secureOutbound and secureInbound in the ConnectionEncrypter interface is now an options object

Change checklist

  • [x] I have performed a self-review of my own code
  • [x] I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • [x] I have added tests that prove my fix is effective or that my feature works

achingbrain avatar Aug 14 '24 10:08 achingbrain