Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: update interface-store to 5.x.x #63

Merged
merged 2 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/gc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/helia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 6 additions & 5 deletions packages/helia/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PutBlockProgressEvents> = {}): Promise<void> {
async put (cid: CID, block: Uint8Array, options: AbortOptions & ProgressOptions<PutBlockProgressEvents> = {}): Promise<CID> {
const releaseLock = await this.lock.readLock()

try {
if (await this.child.has(cid)) {
options.onProgress?.(new CustomProgressEvent<CID>('blocks:put:duplicate', cid))
return
return cid
}

if (this.bitswap?.isStarted() === true) {
Expand All @@ -65,7 +65,8 @@ export class BlockStorage implements Blocks {
}

options.onProgress?.(new CustomProgressEvent<CID>('blocks:put:blockstore:put', cid))
await this.child.put(cid, block, options)

return await this.child.put(cid, block, options)
} finally {
releaseLock()
}
Expand All @@ -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<PutManyBlocksProgressEvents> = {}): AsyncIterable<Pair> {
async * putMany (blocks: AwaitIterable<{ cid: CID, block: Uint8Array }>, options: AbortOptions & ProgressOptions<PutManyBlocksProgressEvents> = {}): AsyncIterable<CID> {
const releaseLock = await this.lock.readLock()

try {
Expand Down Expand Up @@ -127,7 +128,7 @@ export class BlockStorage implements Blocks {
/**
* Get multiple blocks back from an (async) iterable of cids
*/
async * getMany (cids: AwaitIterable<CID>, options: AbortOptions & ProgressOptions<GetManyBlocksProgressEvents> = {}): AsyncIterable<Uint8Array> {
async * getMany (cids: AwaitIterable<CID>, options: AbortOptions & ProgressOptions<GetManyBlocksProgressEvents> = {}): AsyncIterable<Pair> {
const releaseLock = await this.lock.readLock()

try {
Expand Down
4 changes: 2 additions & 2 deletions packages/helia/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
16 changes: 8 additions & 8 deletions packages/helia/test/storage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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()
})
Expand All @@ -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 * () {
Expand All @@ -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()
}
})

Expand Down Expand Up @@ -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()
}
})
})
2 changes: 1 addition & 1 deletion packages/interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down