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

Commit 04c8c7f

Browse files
authored
deps!: update to new stream type deps (#272)
libp2p streams are now explicit about the types of sync/sources they provide, showing that they are AsyncGenerators and not just AsyncIterables.
1 parent f459844 commit 04c8c7f

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ dist
66
node_modules
77
package-lock.json
88
yarn.lock
9+
.vscode

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,23 +147,23 @@
147147
"docs": "aegir docs"
148148
},
149149
"dependencies": {
150-
"@libp2p/interface-connection": "^4.0.0",
151-
"@libp2p/interface-stream-muxer": "^3.0.0",
150+
"@libp2p/interface-connection": "^5.0.0",
151+
"@libp2p/interface-stream-muxer": "^4.0.0",
152152
"@libp2p/interfaces": "^3.2.0",
153153
"@libp2p/logger": "^2.0.0",
154154
"abortable-iterator": "^4.0.2",
155155
"any-signal": "^4.0.1",
156156
"benchmark": "^2.1.4",
157-
"it-batched-bytes": "^1.0.0",
157+
"it-batched-bytes": "^2.0.2",
158158
"it-pushable": "^3.1.0",
159-
"it-stream-types": "^1.0.4",
159+
"it-stream-types": "^2.0.1",
160160
"rate-limiter-flexible": "^2.3.9",
161161
"uint8arraylist": "^2.1.1",
162162
"uint8arrays": "^4.0.2",
163163
"varint": "^6.0.0"
164164
},
165165
"devDependencies": {
166-
"@libp2p/interface-stream-muxer-compliance-tests": "^6.0.0",
166+
"@libp2p/interface-stream-muxer-compliance-tests": "^7.0.0",
167167
"@types/varint": "^6.0.0",
168168
"aegir": "^38.1.7",
169169
"cborg": "^1.8.1",

src/decode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class Decoder {
2525
this._maxUnprocessedMessageQueueSize = maxUnprocessedMessageQueueSize
2626
}
2727

28-
write (chunk: Uint8Array): Message[] {
28+
write (chunk: Uint8Array | Uint8ArrayList): Message[] {
2929
if (chunk == null || chunk.length === 0) {
3030
return []
3131
}

src/mplex.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { toString as uint8ArrayToString } from 'uint8arrays'
88
import { logger } from '@libp2p/logger'
99
import { CodeError } from '@libp2p/interfaces/errors'
1010
import { RateLimiterMemory } from 'rate-limiter-flexible'
11-
import type { Sink } from 'it-stream-types'
11+
import type { Sink, Source } from 'it-stream-types'
1212
import type { StreamMuxer, StreamMuxerInit } from '@libp2p/interface-stream-muxer'
1313
import type { Stream } from '@libp2p/interface-connection'
1414
import type { MplexInit } from './index.js'
@@ -49,8 +49,8 @@ interface MplexStreamMuxerInit extends MplexInit, StreamMuxerInit {}
4949
export class MplexStreamMuxer implements StreamMuxer {
5050
public protocol = '/mplex/6.7.0'
5151

52-
public sink: Sink<Uint8Array>
53-
public source: AsyncIterable<Uint8Array>
52+
public sink: Sink<Source<Uint8ArrayList | Uint8Array>, Promise<void>>
53+
public source: AsyncGenerator<Uint8Array>
5454

5555
private _streamId: number
5656
private readonly _streams: { initiators: Map<number, MplexStream>, receivers: Map<number, MplexStream> }
@@ -190,8 +190,8 @@ export class MplexStreamMuxer implements StreamMuxer {
190190
* Creates a sink with an abortable source. Incoming messages will
191191
* also have their size restricted. All messages will be varint decoded.
192192
*/
193-
_createSink (): Sink<Uint8Array> {
194-
const sink: Sink<Uint8Array> = async source => {
193+
_createSink (): Sink<Source<Uint8ArrayList | Uint8Array>, Promise<void>> {
194+
const sink: Sink<Source<Uint8ArrayList | Uint8Array>, Promise<void>> = async source => {
195195
const signal = anySignal([this.closeController.signal, this._init.signal])
196196

197197
try {

0 commit comments

Comments
 (0)