File tree Expand file tree Collapse file tree 2 files changed +11
-15
lines changed Expand file tree Collapse file tree 2 files changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -283,17 +283,15 @@ class Bitswap {
283283 async putMany ( blocks ) { // eslint-disable-line require-await
284284 const self = this
285285
286- return this . blockstore . putMany ( async function * ( ) {
287- for await ( const block of blocks ) {
288- if ( await self . blockstore . has ( block . cid ) ) {
289- continue
290- }
286+ for await ( const block of blocks ) {
287+ if ( await self . blockstore . has ( block . cid ) ) {
288+ continue
289+ }
291290
292- yield block
291+ await this . blockstore . put ( block )
293292
294- self . _sendHaveBlockNotifications ( block )
295- }
296- } ( ) )
293+ self . _sendHaveBlockNotifications ( block )
294+ }
297295 }
298296
299297 /**
Original file line number Diff line number Diff line change @@ -89,17 +89,15 @@ describe('bitswap without DHT', function () {
8989 // slow blockstore
9090 nodes [ 0 ] . bitswap . blockstore = {
9191 has : sinon . stub ( ) . withArgs ( block . cid ) . returns ( false ) ,
92- putMany : async function * ( source ) { // eslint-disable-line require-await
93- yield * source
94- }
92+ put : sinon . stub ( )
9593 }
9694
9795 // add the block to our want list
9896 const wantBlockPromise1 = nodes [ 0 ] . bitswap . get ( block . cid )
9997
100- // oh look, a peer has sent it to us - this will trigger a `blockstore.putMany ` which
101- // for our purposes is a batch operation so `self.blockstore.has(cid)` will still return
102- // false even though we've just yielded a block with that cid
98+ // oh look, a peer has sent it to us - this will trigger a `blockstore.put ` which
99+ // is an async operation so `self.blockstore.has(cid)` will still return false
100+ // until the write has completed
103101 await nodes [ 0 ] . bitswap . _receiveMessage ( peerId , message )
104102
105103 // block store did not have it
You can’t perform that action at this time.
0 commit comments