@@ -6,8 +6,21 @@ import type { Multiaddr } from '@multiformats/multiaddr'
6
6
import type { ProgressOptions , ProgressEvent } from 'progress-events'
7
7
8
8
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
+ */
9
13
'listening' : CustomEvent
14
+
15
+ /**
16
+ * Emitted if listening on an address failed
17
+ */
10
18
'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
+ */
11
24
'close' : CustomEvent
12
25
}
13
26
@@ -30,15 +43,21 @@ export interface Listener extends TypedEventTarget<ListenerEvents> {
30
43
31
44
export const transportSymbol = Symbol . for ( '@libp2p/transport' )
32
45
33
- export interface ConnectionHandler { ( connection : Connection ) : void }
34
-
35
46
export interface MultiaddrFilter { ( multiaddrs : Multiaddr [ ] ) : Multiaddr [ ] }
36
47
37
48
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
+ */
38
53
upgrader : Upgrader
39
54
}
40
55
41
56
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
+ */
42
61
upgrader : Upgrader
43
62
}
44
63
@@ -115,12 +134,13 @@ ProgressEvent<'upgrader:multiplex-outbound-connection'>
115
134
116
135
export interface Upgrader {
117
136
/**
118
- * Upgrades an outbound connection on `transport. dial`
137
+ * Upgrades an outbound connection created by the ` dial` method of a transport
119
138
*/
120
139
upgradeOutbound ( maConn : MultiaddrConnection , opts ?: UpgraderOptions < OutboundConnectionUpgradeEvents > ) : Promise < Connection >
121
140
122
141
/**
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
124
144
*/
125
145
upgradeInbound ( maConn : MultiaddrConnection , opts ?: UpgraderOptions < InboundConnectionUpgradeEvents > ) : Promise < void >
126
146
}
0 commit comments