Skip to content

Commit

Permalink
fix: temporary fix to support blobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Shaw committed May 17, 2024
1 parent 424671e commit c43e60f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,20 @@ export class DagHausBlockStore {
if (idxEntries.length === 0) return

for (const { key, offset, length } of idxEntries) {
if (key.endsWith('.blob') && this.carpark) {
const blobKey = new URL(key).pathname.slice(1)
const obj = await this.carpark.get(blobKey, { range: { offset, length } })
if (obj) {
const buff = await obj.arrayBuffer()
const bytes = new Uint8Array(buff)
this.metrics.blocks++
this.metrics.blockBytes += bytes.byteLength
this.metrics.blocksR2++
this.metrics.blockBytesR2 += bytes.byteLength
return bytes
}
}

const carKey = toCarKey(key)
if (carKey && this.carpark) {
const obj = await this.carpark.get(carKey, { range: { offset, length } })
Expand Down

0 comments on commit c43e60f

Please sign in to comment.