File tree 2 files changed +11
-15
lines changed
2 files changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -283,17 +283,15 @@ class Bitswap {
283
283
async putMany ( blocks ) { // eslint-disable-line require-await
284
284
const self = this
285
285
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
+ }
291
290
292
- yield block
291
+ await this . blockstore . put ( block )
293
292
294
- self . _sendHaveBlockNotifications ( block )
295
- }
296
- } ( ) )
293
+ self . _sendHaveBlockNotifications ( block )
294
+ }
297
295
}
298
296
299
297
/**
Original file line number Diff line number Diff line change @@ -89,17 +89,15 @@ describe('bitswap without DHT', function () {
89
89
// slow blockstore
90
90
nodes [ 0 ] . bitswap . blockstore = {
91
91
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 ( )
95
93
}
96
94
97
95
// add the block to our want list
98
96
const wantBlockPromise1 = nodes [ 0 ] . bitswap . get ( block . cid )
99
97
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
103
101
await nodes [ 0 ] . bitswap . _receiveMessage ( peerId , message )
104
102
105
103
// block store did not have it
You can’t perform that action at this time.
0 commit comments