Skip to content

Commit

Permalink
chore: appease linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Shaw committed Sep 14, 2023
1 parent 462c8a4 commit 630172b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
20 changes: 11 additions & 9 deletions packages/upload-client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,17 @@ async function uploadBlockStream(conf, blocks, options = {}) {
const concurrency = options.concurrentRequests ?? CONCURRENT_REQUESTS
await blocks
.pipeThrough(new ShardingStream(options))
.pipeThrough(new Parallel(concurrency, async car => {
const bytes = new Uint8Array(await car.arrayBuffer())
const [cid, piece] = await Promise.all([
Store.add(conf, bytes, options),
Piece.fromPayload(bytes)
])
const { version, roots, size } = car
return { version, roots, size, cid, piece: piece.link }
}))
.pipeThrough(
new Parallel(concurrency, async (car) => {
const bytes = new Uint8Array(await car.arrayBuffer())
const [cid, piece] = await Promise.all([
Store.add(conf, bytes, options),
Piece.fromPayload(bytes),
])
const { version, roots, size } = car
return { version, roots, size, cid, piece: piece.link }
})
)
.pipeTo(
new WritableStream({
write(meta) {
Expand Down
3 changes: 2 additions & 1 deletion packages/upload-client/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export async function add(
options = {}
) {
// TODO: validate blob contains CAR data
const bytes = car instanceof Uint8Array ? car : new Uint8Array(await car.arrayBuffer())
const bytes =
car instanceof Uint8Array ? car : new Uint8Array(await car.arrayBuffer())
const link = await CAR.codec.link(bytes)
/* c8 ignore next */
const conn = options.connection ?? connection
Expand Down
7 changes: 5 additions & 2 deletions packages/upload-client/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ describe('uploadCAR', () => {
car,
{
connection,
onShardStored: (meta) => pieceCIDs.push(meta.piece)
onShardStored: (meta) => pieceCIDs.push(meta.piece),
}
)

Expand All @@ -568,6 +568,9 @@ describe('uploadCAR', () => {
assert(service.upload.add.called)
assert.equal(service.upload.add.callCount, 1)
assert.equal(pieceCIDs.length, 1)
assert.equal(pieceCIDs[0].toString(), 'bafkzcibbammseumg3mjlev5odi5bpcsrp4gg62d7xnx44zkxzvgedq7nxldbc')
assert.equal(
pieceCIDs[0].toString(),
'bafkzcibbammseumg3mjlev5odi5bpcsrp4gg62d7xnx44zkxzvgedq7nxldbc'
)
})
})

0 comments on commit 630172b

Please sign in to comment.