Skip to content
This repository was archived by the owner on Jul 21, 2023. It is now read-only.

Commit 43db1cb

Browse files
authored
fix: update interfaces (#160)
Updates to the latest libp2p interfaces
1 parent 0137b94 commit 43db1cb

File tree

1 file changed

+5
-29
lines changed

1 file changed

+5
-29
lines changed

src/index.ts

+5-29
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import { createStream } from './stream.js'
99
import { toString as uint8ArrayToString } from 'uint8arrays'
1010
import { trackedMap } from '@libp2p/tracked-map'
1111
import { logger } from '@libp2p/logger'
12-
import type { AbortOptions } from '@libp2p/interfaces'
1312
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'
1514
import type { Stream } from '@libp2p/interfaces/connection'
1615
import type { ComponentMetricsTracker } from '@libp2p/interfaces/metrics'
1716
import each from 'it-foreach'
@@ -39,9 +38,7 @@ export interface MplexStream extends Stream {
3938
source: Pushable<Uint8Array>
4039
}
4140

42-
export interface MplexOptions extends AbortOptions {
43-
onStream?: (...args: any[]) => void
44-
onStreamEnd?: (...args: any[]) => void
41+
export interface MplexOptions extends MuxerOptions {
4542
maxMsgSize?: number
4643
metrics?: ComponentMetricsTracker
4744
}
@@ -207,28 +204,7 @@ export class Mplex implements Muxer {
207204
}
208205
}
209206
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+
232208
return Object.assign(encode(source), {
233209
push: source.push,
234210
end: source.end,
@@ -247,8 +223,8 @@ export class Mplex implements Muxer {
247223
if (message.type === MessageTypes.NEW_STREAM) {
248224
const stream = this._newReceiverStream({ id, name: uint8ArrayToString(message.data instanceof Uint8Array ? message.data : message.data.slice()) })
249225

250-
if (this._options.onStream != null) {
251-
this._options.onStream(stream)
226+
if (this._options.onIncomingStream != null) {
227+
this._options.onIncomingStream(stream)
252228
}
253229

254230
return

0 commit comments

Comments
 (0)