Skip to content

Commit

Permalink
chore: update utils
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Feb 6, 2024
1 parent d1228b9 commit 32713ab
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/utils/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ export class BlockStorage implements Blocks, Startable {
}
}

async createSession (root: CID, options?: AbortOptions): Promise<Blocks> {
async createSession (root: CID, options?: AbortOptions): Promise<Blockstore> {
const releaseLock = await this.lock.readLock()

try {
const blocks = await this.child.createSession?.(root, options)
const blocks = await this.child.createSession(root, options)

if (blocks == null) {
throw new CodeError('Sessions not supported', 'ERR_UNSUPPORTED')
Expand Down
4 changes: 0 additions & 4 deletions packages/utils/src/utils/networked-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ export class NetworkedStorage implements Blocks, Startable {
this.blockBrokers.map(async broker => broker.announce?.(cid, block, options))
)

await Promise.all(
this.blockBrokers.map(async broker => broker.announce?.(cid, block, options))
)

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

return this.child.put(cid, block, options)
Expand Down
9 changes: 8 additions & 1 deletion packages/utils/test/storage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ import { BlockStorage } from '../src/storage.js'
import { createBlock } from './fixtures/create-block.js'
import type { Blocks } from '@helia/interface'
import type { Pins } from '@helia/interface/pins'
import type { Blockstore } from 'interface-blockstore'
import type { CID } from 'multiformats/cid'

class MemoryBlocks extends MemoryBlockstore implements Blocks {
async createSession (): Promise<Blockstore> {
throw new Error('Not implemented')
}

Check warning on line 21 in packages/utils/test/storage.spec.ts

View check run for this annotation

Codecov / codecov/patch

packages/utils/test/storage.spec.ts#L20-L21

Added lines #L20 - L21 were not covered by tests
}

describe('storage', () => {
let storage: BlockStorage
let blockstore: Blocks
Expand All @@ -29,7 +36,7 @@ describe('storage', () => {

const datastore = new MemoryDatastore()

blockstore = new MemoryBlockstore()
blockstore = new MemoryBlocks()
pins = new PinsImpl(datastore, blockstore, [])
storage = new BlockStorage(blockstore, pins, {
holdGcLock: true
Expand Down

0 comments on commit 32713ab

Please sign in to comment.