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

Commit

Permalink
chore: revert "fix: make connection upgrade and encryption abortable" (
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
achingbrain authored Dec 24, 2021
1 parent 7d8be60 commit 9d52223
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 2 additions & 3 deletions packages/libp2p-interfaces/src/crypto/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { PeerId } from '../peer-id'
import type { MultiaddrConnection } from '../transport'
import type { AbortOptions } from '../index'

/**
* A libp2p crypto module must be compliant to this interface
Expand All @@ -11,11 +10,11 @@ export interface Crypto {
/**
* Encrypt outgoing data to the remote party.
*/
secureOutbound: (localPeer: PeerId, connection: MultiaddrConnection, remotePeer: PeerId, options?: AbortOptions) => Promise<SecureOutbound>
secureOutbound: (localPeer: PeerId, connection: MultiaddrConnection, remotePeer: PeerId) => Promise<SecureOutbound>
/**
* Decrypt incoming data.
*/
secureInbound: (localPeer: PeerId, connection: MultiaddrConnection, remotePeer?: PeerId, options?: AbortOptions) => Promise<SecureOutbound>
secureInbound: (localPeer: PeerId, connection: MultiaddrConnection, remotePeer?: PeerId) => Promise<SecureOutbound>
}

export interface SecureOutbound {
Expand Down
9 changes: 6 additions & 3 deletions packages/libp2p-interfaces/src/transport/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type events from 'events'
import type { Multiaddr } from 'multiaddr'
import type { Connection } from '../connection'
import type { AbortOptions } from '../index'

export interface AbortOptions {
signal?: AbortSignal
}

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

/**
* Upgrades an inbound connection on transport listener.
*/
upgradeInbound: (maConn: MultiaddrConnection, options?: AbortOptions) => Promise<Connection>
upgradeInbound: (maConn: MultiaddrConnection) => Promise<Connection>
}

export interface MultiaddrConnectionTimeline {
Expand Down

0 comments on commit 9d52223

Please sign in to comment.