Skip to content

Commit 656db81

Browse files
authoredNov 18, 2024··
fix: update transport listener options (#2826)
Will cause a release that includes changes added as part of a previous `chore:` commit.
1 parent 5feb1bb commit 656db81

File tree

1 file changed

+24
-4
lines changed
  • packages/interface/src/transport

1 file changed

+24
-4
lines changed
 

‎packages/interface/src/transport/index.ts

+24-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,21 @@ import type { Multiaddr } from '@multiformats/multiaddr'
66
import type { ProgressOptions, ProgressEvent } from 'progress-events'
77

88
export interface ListenerEvents {
9+
/**
10+
* This event signals to the transport manager that the listening addresses
11+
* have changed and may be emitted at any point and/or multiple times
12+
*/
913
'listening': CustomEvent
14+
15+
/**
16+
* Emitted if listening on an address failed
17+
*/
1018
'error': CustomEvent<Error>
19+
20+
/**
21+
* Emitted when the listener has been shut down, has no open connections and
22+
* will no longer accept new connections
23+
*/
1124
'close': CustomEvent
1225
}
1326

@@ -30,15 +43,21 @@ export interface Listener extends TypedEventTarget<ListenerEvents> {
3043

3144
export const transportSymbol = Symbol.for('@libp2p/transport')
3245

33-
export interface ConnectionHandler { (connection: Connection): void }
34-
3546
export interface MultiaddrFilter { (multiaddrs: Multiaddr[]): Multiaddr[] }
3647

3748
export interface CreateListenerOptions {
49+
/**
50+
* The upgrader turns a MultiaddrConnection into a Connection and notifies
51+
* other libp2p components about a new incoming connection.
52+
*/
3853
upgrader: Upgrader
3954
}
4055

4156
export interface DialTransportOptions<DialEvents extends ProgressEvent = ProgressEvent> extends AbortOptions, ProgressOptions<DialEvents> {
57+
/**
58+
* The upgrader turns a MultiaddrConnection into a Connection which should be
59+
* returned by the transport's dial method
60+
*/
4261
upgrader: Upgrader
4362
}
4463

@@ -115,12 +134,13 @@ ProgressEvent<'upgrader:multiplex-outbound-connection'>
115134

116135
export interface Upgrader {
117136
/**
118-
* Upgrades an outbound connection on `transport.dial`
137+
* Upgrades an outbound connection created by the `dial` method of a transport
119138
*/
120139
upgradeOutbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<OutboundConnectionUpgradeEvents>): Promise<Connection>
121140

122141
/**
123-
* Upgrades an inbound connection received by a transport listener
142+
* Upgrades an inbound connection received by a transport listener and
143+
* notifies other libp2p components about the new connection
124144
*/
125145
upgradeInbound(maConn: MultiaddrConnection, opts?: UpgraderOptions<InboundConnectionUpgradeEvents>): Promise<void>
126146
}

0 commit comments

Comments
 (0)
Please sign in to comment.