Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

Commit 9d52223

Browse files
authored
chore: revert "fix: make connection upgrade and encryption abortable" (#125)
This is the wrong fix - the maconn should be aborted at the source rather than each use of it. We have a `TimeoutController` that is passed in to the connection that should abort it if the upgrade/crypto handshake isn't completed in time, but at the moment `abortable-iterator` doesn't reject when reads stall indefinitely - fix for that in alanshaw/abortable-iterator#15
1 parent 7d8be60 commit 9d52223

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

packages/libp2p-interfaces/src/crypto/index.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { PeerId } from '../peer-id'
22
import type { MultiaddrConnection } from '../transport'
3-
import type { AbortOptions } from '../index'
43

54
/**
65
* A libp2p crypto module must be compliant to this interface
@@ -11,11 +10,11 @@ export interface Crypto {
1110
/**
1211
* Encrypt outgoing data to the remote party.
1312
*/
14-
secureOutbound: (localPeer: PeerId, connection: MultiaddrConnection, remotePeer: PeerId, options?: AbortOptions) => Promise<SecureOutbound>
13+
secureOutbound: (localPeer: PeerId, connection: MultiaddrConnection, remotePeer: PeerId) => Promise<SecureOutbound>
1514
/**
1615
* Decrypt incoming data.
1716
*/
18-
secureInbound: (localPeer: PeerId, connection: MultiaddrConnection, remotePeer?: PeerId, options?: AbortOptions) => Promise<SecureOutbound>
17+
secureInbound: (localPeer: PeerId, connection: MultiaddrConnection, remotePeer?: PeerId) => Promise<SecureOutbound>
1918
}
2019

2120
export interface SecureOutbound {

packages/libp2p-interfaces/src/transport/index.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import type events from 'events'
22
import type { Multiaddr } from 'multiaddr'
33
import type { Connection } from '../connection'
4-
import type { AbortOptions } from '../index'
4+
5+
export interface AbortOptions {
6+
signal?: AbortSignal
7+
}
58

69
export interface TransportFactory<DialOptions extends { signal?: AbortSignal }, ListenerOptions> {
710
new(upgrader: Upgrader): Transport<DialOptions, ListenerOptions>
@@ -48,12 +51,12 @@ export interface Upgrader {
4851
/**
4952
* Upgrades an outbound connection on `transport.dial`.
5053
*/
51-
upgradeOutbound: (maConn: MultiaddrConnection, options?: AbortOptions) => Promise<Connection>
54+
upgradeOutbound: (maConn: MultiaddrConnection) => Promise<Connection>
5255

5356
/**
5457
* Upgrades an inbound connection on transport listener.
5558
*/
56-
upgradeInbound: (maConn: MultiaddrConnection, options?: AbortOptions) => Promise<Connection>
59+
upgradeInbound: (maConn: MultiaddrConnection) => Promise<Connection>
5760
}
5861

5962
export interface MultiaddrConnectionTimeline {

0 commit comments

Comments
 (0)