Skip to content

Commit

Permalink
fix: move mplex capabilities to the factory (#2597)
Browse files Browse the repository at this point in the history
These should be defined on the factory not the instance, since the
factory is the component.
  • Loading branch information
achingbrain authored Jun 23, 2024
1 parent 703b390 commit 0b55625
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 7 additions & 0 deletions packages/stream-multiplexer-mplex/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* ```
*/

import { serviceCapabilities } from '@libp2p/interface'
import { MplexStreamMuxer, type MplexComponents } from './mplex.js'
import type { StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface'

Expand Down Expand Up @@ -91,6 +92,12 @@ class Mplex implements StreamMuxerFactory {
this._init = init
}

readonly [Symbol.toStringTag] = '@libp2p/mplex'

readonly [serviceCapabilities]: string[] = [
'@libp2p/stream-multiplexing'
]

createStreamMuxer (init: StreamMuxerInit = {}): StreamMuxer {
return new MplexStreamMuxer(this.components, {
...init,
Expand Down
8 changes: 1 addition & 7 deletions packages/stream-multiplexer-mplex/src/mplex.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CodeError, serviceCapabilities } from '@libp2p/interface'
import { CodeError } from '@libp2p/interface'
import { closeSource } from '@libp2p/utils/close-source'
import { RateLimiter } from '@libp2p/utils/rate-limiter'
import { pipe } from 'it-pipe'
Expand Down Expand Up @@ -120,12 +120,6 @@ export class MplexStreamMuxer implements StreamMuxer {
})
}

readonly [Symbol.toStringTag] = '@libp2p/mplex'

readonly [serviceCapabilities]: string[] = [
'@libp2p/stream-multiplexing'
]

/**
* Returns a Map of streams and their ids
*/
Expand Down

0 comments on commit 0b55625

Please sign in to comment.