chore: make inboundStream a asyncIterable

This commit is contained in:
Vasco Santos 2020-12-02 18:16:39 +01:00
parent 5cb2025c2a
commit 5cfaf4128f
2 changed files with 3 additions and 3 deletions

View File

@ -24,6 +24,7 @@ const {
/**
* @typedef {any} Libp2p
* @typedef {import('peer-id')} PeerId
* @typedef {import('bl')} BufferList
* @typedef {import('../stream-muxer/types').MuxedStream} MuxedStream
* @typedef {import('../connection/connection')} Connection
* @typedef {import('./message').RPC} RPC
@ -339,7 +340,7 @@ class PubsubBaseProtocol extends EventEmitter {
* Responsible for processing each RPC message received by other peers.
*
* @param {string} idB58Str - peer id string in base58
* @param {MuxedStream} stream - inbound stream
* @param {AsyncIterable<Uint8Array|BufferList>} stream - inbound stream
* @param {PeerStreams} peerStreams - PubSub peer
* @returns {Promise<void>}
*/

View File

@ -73,7 +73,7 @@ class PeerStreams extends EventEmitter {
/**
* Read stream
*
* @type {null|MuxedStream}
* @type {null| AsyncIterable<Uint8Array>}
*/
this.inboundStream = null
}
@ -125,7 +125,6 @@ class PeerStreams extends EventEmitter {
// - abortable, set to only return on abort, rather than throw
// - transformed with length-prefix transform
this._rawInboundStream = stream
// @ts-ignore - abortable returns AsyncIterable and not a MuxedStream
this.inboundStream = abortable(
pipe(
this._rawInboundStream,