@@ -9,9 +9,8 @@ import { createStream } from './stream.js'
9
9
import { toString as uint8ArrayToString } from 'uint8arrays'
10
10
import { trackedMap } from '@libp2p/tracked-map'
11
11
import { logger } from '@libp2p/logger'
12
- import type { AbortOptions } from '@libp2p/interfaces'
13
12
import type { Sink } from 'it-stream-types'
14
- import type { Muxer } from '@libp2p/interfaces/stream-muxer'
13
+ import type { Muxer , MuxerOptions } from '@libp2p/interfaces/stream-muxer'
15
14
import type { Stream } from '@libp2p/interfaces/connection'
16
15
import type { ComponentMetricsTracker } from '@libp2p/interfaces/metrics'
17
16
import each from 'it-foreach'
@@ -39,9 +38,7 @@ export interface MplexStream extends Stream {
39
38
source : Pushable < Uint8Array >
40
39
}
41
40
42
- export interface MplexOptions extends AbortOptions {
43
- onStream ?: ( ...args : any [ ] ) => void
44
- onStreamEnd ?: ( ...args : any [ ] ) => void
41
+ export interface MplexOptions extends MuxerOptions {
45
42
maxMsgSize ?: number
46
43
metrics ?: ComponentMetricsTracker
47
44
}
@@ -207,28 +204,7 @@ export class Mplex implements Muxer {
207
204
}
208
205
}
209
206
const source = pushableV < Message > ( { onEnd } )
210
- /*
211
- const p = pipe(
212
- source,
213
- source => each(source, (msgs) => {
214
- if (log.enabled) {
215
- msgs.forEach(msg => {
216
- log('outgoing message', printMessage(msg))
217
- })
218
- }
219
- }),
220
- source => encode(source),
221
- source => each(source, (buf) => {
222
- console.info('outgoing', uint8ArrayToString(buf, 'base64'))
223
- })
224
- )
225
-
226
- return Object.assign(p, {
227
- push: source.push,
228
- end: source.end,
229
- return: source.return
230
- })
231
- */
207
+
232
208
return Object . assign ( encode ( source ) , {
233
209
push : source . push ,
234
210
end : source . end ,
@@ -247,8 +223,8 @@ export class Mplex implements Muxer {
247
223
if ( message . type === MessageTypes . NEW_STREAM ) {
248
224
const stream = this . _newReceiverStream ( { id, name : uint8ArrayToString ( message . data instanceof Uint8Array ? message . data : message . data . slice ( ) ) } )
249
225
250
- if ( this . _options . onStream != null ) {
251
- this . _options . onStream ( stream )
226
+ if ( this . _options . onIncomingStream != null ) {
227
+ this . _options . onIncomingStream ( stream )
252
228
}
253
229
254
230
return
0 commit comments