From 5bf11d638eee423624ac49af97757d730744f384 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Thu, 23 Mar 2023 11:09:49 +0000 Subject: [PATCH] deps: update interface-store to 5.x.x (#63) --- benchmarks/gc/package.json | 2 +- packages/helia/package.json | 2 +- packages/helia/src/storage.ts | 11 ++++++----- packages/helia/test/index.spec.ts | 4 ++-- packages/helia/test/storage.spec.ts | 16 ++++++++-------- packages/interface/package.json | 2 +- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/benchmarks/gc/package.json b/benchmarks/gc/package.json index 149b615b..52847a4b 100644 --- a/benchmarks/gc/package.json +++ b/benchmarks/gc/package.json @@ -17,7 +17,7 @@ "@ipld/dag-pb": "^4.0.2", "@libp2p/websockets": "^5.0.3", "aegir": "^38.1.5", - "blockstore-fs": "^1.0.0", + "blockstore-fs": "^1.0.1", "datastore-level": "^10.0.1", "execa": "^7.0.0", "go-ipfs": "^0.18.1", diff --git a/packages/helia/package.json b/packages/helia/package.json index f3c666dc..41922f49 100644 --- a/packages/helia/package.json +++ b/packages/helia/package.json @@ -62,7 +62,7 @@ "datastore-core": "^9.0.0", "interface-blockstore": "^5.0.0", "interface-datastore": "^8.0.0", - "interface-store": "^4.0.0", + "interface-store": "^5.0.1", "ipfs-bitswap": "^17.0.0", "it-all": "^2.0.0", "it-drain": "^2.0.0", diff --git a/packages/helia/src/storage.ts b/packages/helia/src/storage.ts index ffda475f..3606b92e 100644 --- a/packages/helia/src/storage.ts +++ b/packages/helia/src/storage.ts @@ -50,13 +50,13 @@ export class BlockStorage implements Blocks { /** * Put a block to the underlying datastore */ - async put (cid: CID, block: Uint8Array, options: AbortOptions & ProgressOptions = {}): Promise { + async put (cid: CID, block: Uint8Array, options: AbortOptions & ProgressOptions = {}): Promise { const releaseLock = await this.lock.readLock() try { if (await this.child.has(cid)) { options.onProgress?.(new CustomProgressEvent('blocks:put:duplicate', cid)) - return + return cid } if (this.bitswap?.isStarted() === true) { @@ -65,7 +65,8 @@ export class BlockStorage implements Blocks { } options.onProgress?.(new CustomProgressEvent('blocks:put:blockstore:put', cid)) - await this.child.put(cid, block, options) + + return await this.child.put(cid, block, options) } finally { releaseLock() } @@ -74,7 +75,7 @@ export class BlockStorage implements Blocks { /** * Put a multiple blocks to the underlying datastore */ - async * putMany (blocks: AwaitIterable<{ cid: CID, block: Uint8Array }>, options: AbortOptions & ProgressOptions = {}): AsyncIterable { + async * putMany (blocks: AwaitIterable<{ cid: CID, block: Uint8Array }>, options: AbortOptions & ProgressOptions = {}): AsyncIterable { const releaseLock = await this.lock.readLock() try { @@ -127,7 +128,7 @@ export class BlockStorage implements Blocks { /** * Get multiple blocks back from an (async) iterable of cids */ - async * getMany (cids: AwaitIterable, options: AbortOptions & ProgressOptions = {}): AsyncIterable { + async * getMany (cids: AwaitIterable, options: AbortOptions & ProgressOptions = {}): AsyncIterable { const releaseLock = await this.lock.readLock() try { diff --git a/packages/helia/test/index.spec.ts b/packages/helia/test/index.spec.ts index 8445b597..d33f98d7 100644 --- a/packages/helia/test/index.spec.ts +++ b/packages/helia/test/index.spec.ts @@ -86,11 +86,11 @@ describe('helia', () => { const cid = CID.parse('QmaQwYWpchozXhFv8nvxprECWBSCEppN9dfd2VQiJfRo3F') const block = Uint8Array.from([0, 1, 2, 3]) await helia.blockstore.put(cid, block) - await expect(helia.blockstore.has(cid)).to.eventually.be.true() + expect(await helia.blockstore.has(cid)).to.be.true() const key = new Key(`/${cid.toString()}`) await helia.datastore.put(key, block) - await expect(helia.datastore.has(key)).to.eventually.be.true() + expect(await helia.datastore.has(key)).to.be.true() expect(() => { helia.libp2p.isStarted() diff --git a/packages/helia/test/storage.spec.ts b/packages/helia/test/storage.spec.ts index aabd6891..65964e9f 100644 --- a/packages/helia/test/storage.spec.ts +++ b/packages/helia/test/storage.spec.ts @@ -77,7 +77,7 @@ describe('storage', () => { } }())) - expect(retrieved).to.deep.equal(new Array(count).fill(0).map((_, i) => blocks[i].block)) + expect(retrieved).to.deep.equal(new Array(count).fill(0).map((_, i) => blocks[i])) }) it('puts a block into the blockstore', async () => { @@ -108,11 +108,11 @@ describe('storage', () => { bitswap.isStarted.returns(true) bitswap.want.withArgs(cid).resolves(block) - await expect(blockstore.has(cid)).to.eventually.be.false() + expect(await blockstore.has(cid)).to.be.false() const returned = await storage.get(cid) - await expect(blockstore.has(cid)).to.eventually.be.true() + expect(await blockstore.has(cid)).to.be.true() expect(returned).to.equalBytes(block) expect(bitswap.want.called).to.be.true() }) @@ -126,7 +126,7 @@ describe('storage', () => { const { cid, block } = blocks[i] bitswap.want.withArgs(cid).resolves(block) - await expect(blockstore.has(cid)).to.eventually.be.false() + expect(await blockstore.has(cid)).to.be.false() } const retrieved = await all(storage.getMany(async function * () { @@ -136,12 +136,12 @@ describe('storage', () => { } }())) - expect(retrieved).to.deep.equal(new Array(count).fill(0).map((_, i) => blocks[i].block)) + expect(retrieved).to.deep.equal(new Array(count).fill(0).map((_, i) => blocks[i])) for (let i = 0; i < count; i++) { const { cid } = blocks[i] expect(bitswap.want.calledWith(cid)).to.be.true() - await expect(blockstore.has(cid)).to.eventually.be.true() + expect(await blockstore.has(cid)).to.be.true() } }) @@ -169,10 +169,10 @@ describe('storage', () => { } }())) - expect(retrieved).to.deep.equal(new Array(count).fill(0).map((_, i) => blocks[i].block)) + expect(retrieved).to.deep.equal(new Array(count).fill(0).map((_, i) => blocks[i])) for (let i = 0; i < count; i++) { - await expect(blockstore.has(blocks[i].cid)).to.eventually.be.true() + expect(await blockstore.has(blocks[i].cid)).to.be.true() } }) }) diff --git a/packages/interface/package.json b/packages/interface/package.json index cd6e8783..19d6336f 100644 --- a/packages/interface/package.json +++ b/packages/interface/package.json @@ -74,7 +74,7 @@ "@libp2p/interfaces": "^3.3.1", "interface-blockstore": "^5.0.0", "interface-datastore": "^8.0.0", - "interface-store": "^4.0.0", + "interface-store": "^5.0.1", "ipfs-bitswap": "^17.0.0", "multiformats": "^11.0.1", "progress-events": "^1.0.0"