@@ -5,13 +5,14 @@ import { symbol } from '@libp2p/interfaces/connection'
5
5
import type { Connection , ConnectionStat , Metadata , ProtocolStream , Stream } from '@libp2p/interfaces/connection'
6
6
import type { PeerId } from '@libp2p/interfaces/peer-id'
7
7
import { logger } from '@libp2p/logger'
8
+ import type { AbortOptions } from '@libp2p/interfaces'
8
9
9
10
const log = logger ( 'libp2p:connection' )
10
11
11
12
interface ConnectionInit {
12
13
remoteAddr : Multiaddr
13
14
remotePeer : PeerId
14
- newStream : ( protocols : string [ ] ) => Promise < ProtocolStream >
15
+ newStream : ( protocols : string [ ] , options ?: AbortOptions ) => Promise < ProtocolStream >
15
16
close : ( ) => Promise < void >
16
17
getStreams : ( ) => Stream [ ]
17
18
stat : ConnectionStat
@@ -47,7 +48,7 @@ export class ConnectionImpl implements Connection {
47
48
/**
48
49
* Reference to the new stream function of the multiplexer
49
50
*/
50
- private readonly _newStream : ( protocols : string [ ] ) => Promise < ProtocolStream >
51
+ private readonly _newStream : ( protocols : string [ ] , options ?: AbortOptions ) => Promise < ProtocolStream >
51
52
/**
52
53
* Reference to the close function of the raw connection
53
54
*/
@@ -102,7 +103,7 @@ export class ConnectionImpl implements Connection {
102
103
/**
103
104
* Create a new stream from this connection
104
105
*/
105
- async newStream ( protocols : string | string [ ] ) {
106
+ async newStream ( protocols : string | string [ ] , options ?: AbortOptions ) {
106
107
if ( this . stat . status === CLOSING ) {
107
108
throw errCode ( new Error ( 'the connection is being closed' ) , 'ERR_CONNECTION_BEING_CLOSED' )
108
109
}
@@ -115,7 +116,7 @@ export class ConnectionImpl implements Connection {
115
116
protocols = [ protocols ]
116
117
}
117
118
118
- const { stream, protocol } = await this . _newStream ( protocols )
119
+ const { stream, protocol } = await this . _newStream ( protocols , options )
119
120
120
121
this . addStream ( stream , { protocol, metadata : { } } )
121
122
0 commit comments