ipfs-bitswap
Advanced tools
Comparing version 12.0.3 to 12.0.4
{ | ||
"name": "ipfs-bitswap", | ||
"version": "12.0.3", | ||
"version": "12.0.4", | ||
"description": "JavaScript implementation of the Bitswap data exchange protocol used by IPFS", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0 OR MIT", |
@@ -242,20 +242,4 @@ import * as lp from 'it-length-prefixed' | ||
/** @type {Uint8Array} */ | ||
let serialized | ||
switch (stream.stat.protocol) { | ||
case BITSWAP100: | ||
serialized = msg.serializeToBitswap100() | ||
break | ||
case BITSWAP110: | ||
case BITSWAP120: | ||
serialized = msg.serializeToBitswap110() | ||
break | ||
default: | ||
throw new Error('Unknown protocol: ' + stream.stat.protocol) | ||
} | ||
await writeMessage(stream, msg, this._log) | ||
await writeMessage(stream, serialized, this._log) | ||
stream.close() | ||
this._updateSentStats(peer, msg.blocks) | ||
@@ -301,3 +285,3 @@ } | ||
* @param {Stream} stream | ||
* @param {Uint8Array} msg | ||
* @param {Message} msg | ||
* @param {*} log | ||
@@ -307,4 +291,18 @@ */ | ||
try { | ||
/** @type {Uint8Array} */ | ||
let serialized | ||
switch (stream.stat.protocol) { | ||
case BITSWAP100: | ||
serialized = msg.serializeToBitswap100() | ||
break | ||
case BITSWAP110: | ||
case BITSWAP120: | ||
serialized = msg.serializeToBitswap110() | ||
break | ||
default: | ||
throw new Error('Unknown protocol: ' + stream.stat.protocol) | ||
} | ||
await pipe( | ||
[msg], | ||
[serialized], | ||
lp.encode(), | ||
@@ -315,3 +313,5 @@ stream | ||
log(err) | ||
} finally { | ||
stream.close() | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
341846
6521