File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 208
208
"iso-random-stream" : " ^2.0.0" ,
209
209
"it-all" : " ^2.0.0" ,
210
210
"it-drain" : " ^2.0.0" ,
211
- "libp2p" : " next " ,
211
+ "libp2p" : " ^0.42.0 " ,
212
212
"lodash.difference" : " ^4.5.0" ,
213
213
"lodash.flatten" : " ^4.4.0" ,
214
214
"lodash.range" : " ^3.2.0" ,
Original file line number Diff line number Diff line change @@ -455,4 +455,12 @@ export class Bitswap extends BaseBlockstore {
455
455
unwrap ( ) {
456
456
return this . blockstore
457
457
}
458
+
459
+ /**
460
+ * @param {CID } cid
461
+ * @returns {Promise<boolean> }
462
+ */
463
+ has ( cid ) {
464
+ return this . blockstore . has ( cid )
465
+ }
458
466
}
Original file line number Diff line number Diff line change @@ -53,6 +53,30 @@ describe('start/stop', () => {
53
53
} )
54
54
} )
55
55
56
+ describe ( 'blockstore' , ( ) => {
57
+ it ( 'should support .has' , async ( ) => {
58
+ const [ block ] = await makeBlocks ( 1 )
59
+ const libp2p = {
60
+ handle : ( ) => { } ,
61
+ unhandle : ( ) => { } ,
62
+ register : ( ) => { } ,
63
+ unregister : ( ) => { } ,
64
+ getConnections : ( ) => [ ]
65
+ }
66
+ // @ts -ignore not a full libp2p
67
+ const bitswap = new Bitswap ( libp2p , new MemoryBlockstore ( ) )
68
+ await bitswap . start ( )
69
+
70
+ await expect ( bitswap . has ( block . cid ) ) . to . eventually . be . false ( )
71
+
72
+ await bitswap . put ( block . cid , block . data )
73
+
74
+ await expect ( bitswap . has ( block . cid ) ) . to . eventually . be . true ( )
75
+
76
+ await bitswap . stop ( )
77
+ } )
78
+ } )
79
+
56
80
describe ( 'bitswap without DHT' , function ( ) {
57
81
this . timeout ( 20 * 1000 )
58
82
You can’t perform that action at this time.
0 commit comments