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

View File

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