Skip to content

Commit 2dfccee

Browse files
authored
deps: update it-stream-types (libp2p#456)
Updates stream types and abortable iterator
1 parent 5f44814 commit 2dfccee

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

.gitignore

+1
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

+4-4
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
"dependencies": {
145145
"@libp2p/crypto": "^1.0.4",
146146
"@libp2p/interface-address-manager": "^2.0.0",
147-
"@libp2p/interface-connection": "^4.0.0",
147+
"@libp2p/interface-connection": "^5.0.1",
148148
"@libp2p/interface-connection-manager": "^2.0.0",
149149
"@libp2p/interface-dht": "^2.0.0",
150150
"@libp2p/interface-metrics": "^4.0.0",
@@ -160,7 +160,7 @@
160160
"@libp2p/record": "^3.0.0",
161161
"@libp2p/topology": "^4.0.0",
162162
"@multiformats/multiaddr": "^12.0.0",
163-
"abortable-iterator": "^4.0.2",
163+
"abortable-iterator": "^5.0.1",
164164
"any-signal": "^4.1.1",
165165
"datastore-core": "^9.0.1",
166166
"hashlru": "^2.3.0",
@@ -174,7 +174,7 @@
174174
"it-merge": "^3.0.0",
175175
"it-parallel": "^3.0.0",
176176
"it-pipe": "^3.0.0",
177-
"it-stream-types": "^1.0.4",
177+
"it-stream-types": "^2.0.1",
178178
"it-take": "^3.0.1",
179179
"k-bucket": "^5.1.0",
180180
"multiformats": "^11.0.0",
@@ -187,7 +187,7 @@
187187
"varint": "^6.0.0"
188188
},
189189
"devDependencies": {
190-
"@libp2p/interface-mocks": "^9.0.0",
190+
"@libp2p/interface-mocks": "^10.0.2",
191191
"@libp2p/peer-id-factory": "^2.0.0",
192192
"@libp2p/peer-store": "^7.0.0",
193193
"@types/lodash.random": "^3.2.6",

src/network.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type { PeerId } from '@libp2p/interface-peer-id'
1616
import type { AbortOptions } from '@libp2p/interfaces'
1717
import type { Startable } from '@libp2p/interfaces/startable'
1818
import type { Logger } from '@libp2p/logger'
19-
import type { Duplex } from 'it-stream-types'
19+
import type { Duplex, Source } from 'it-stream-types'
2020
import type { PeerInfo } from '@libp2p/interface-peer-info'
2121
import type { Stream } from '@libp2p/interface-connection'
2222
import { abortableDuplex } from 'abortable-iterator'
@@ -149,7 +149,7 @@ export class Network extends EventEmitter<NetworkEvents> implements Startable {
149149
/**
150150
* Write a message to the given stream
151151
*/
152-
async _writeMessage (stream: Duplex<Uint8ArrayList, Uint8ArrayList | Uint8Array>, msg: Uint8Array | Uint8ArrayList, options: AbortOptions): Promise<void> {
152+
async _writeMessage (stream: Duplex<AsyncGenerator<Uint8ArrayList>, Source<Uint8ArrayList | Uint8Array>>, msg: Uint8Array | Uint8ArrayList, options: AbortOptions): Promise<void> {
153153
if (options.signal != null) {
154154
stream = abortableDuplex(stream, options.signal)
155155
}
@@ -167,7 +167,7 @@ export class Network extends EventEmitter<NetworkEvents> implements Startable {
167167
* If no response is received after the specified timeout
168168
* this will error out.
169169
*/
170-
async _writeReadMessage (stream: Duplex<Uint8ArrayList, Uint8ArrayList | Uint8Array>, msg: Uint8Array | Uint8ArrayList, options: AbortOptions): Promise<Message> {
170+
async _writeReadMessage (stream: Duplex<AsyncGenerator<Uint8ArrayList>, Source<Uint8ArrayList | Uint8Array>>, msg: Uint8Array | Uint8ArrayList, options: AbortOptions): Promise<Message> {
171171
if (options.signal != null) {
172172
stream = abortableDuplex(stream, options.signal)
173173
}

test/network.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { mockStream } from '@libp2p/interface-mocks'
1212
import type { DualKadDHT } from '../src/dual-kad-dht.js'
1313
import type { Connection } from '@libp2p/interface-connection'
1414
import type { PeerId } from '@libp2p/interface-peer-id'
15-
import type { Sink } from 'it-stream-types'
15+
import type { Sink, Source } from 'it-stream-types'
1616
import { Uint8ArrayList } from 'uint8arraylist'
1717
import map from 'it-map'
1818
import type { Multiaddr } from '@multiformats/multiaddr'
@@ -68,13 +68,13 @@ describe('Network', () => {
6868
async (source) => all(source)
6969
)
7070

71-
const source = (function * () {
71+
const source = (async function * () {
7272
const array = data
7373

7474
yield * array
7575
})()
7676

77-
const sink: Sink<Uint8ArrayList | Uint8Array> = async source => {
77+
const sink: Sink<Source<Uint8ArrayList | Uint8Array>, Promise<void>> = async source => {
7878
const res = await pipe(
7979
source,
8080
(source) => lp.decode(source),

test/rpc/index.node.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { PeerRouting } from '../../src/peer-routing/index.js'
1818
import type { Validators } from '@libp2p/interface-dht'
1919
import type { Datastore } from 'interface-datastore'
2020
import { RoutingTable } from '../../src/routing-table/index.js'
21-
import type { Duplex } from 'it-stream-types'
21+
import type { Duplex, Source } from 'it-stream-types'
2222
import { mockStream } from '@libp2p/interface-mocks'
2323
import { start } from '@libp2p/interfaces/startable'
2424
import { Uint8ArrayList } from 'uint8arraylist'
@@ -85,8 +85,10 @@ describe('rpc', () => {
8585
(source) => all(source)
8686
)
8787

88-
const duplexStream: Duplex<Uint8ArrayList, Uint8ArrayList | Uint8Array> = {
89-
source,
88+
const duplexStream: Duplex<AsyncGenerator<Uint8ArrayList>, Source<Uint8ArrayList | Uint8Array>, Promise<void>> = {
89+
source: (async function * () {
90+
yield * source
91+
})(),
9092
sink: async (source) => {
9193
const res = await pipe(
9294
source,

0 commit comments

Comments
 (0)