Skip to content

Commit

Permalink
feat: move blob index logic from upload-api to blob-index lib (#1434)
Browse files Browse the repository at this point in the history
The blob index logic should be an independent module as it will be used
in both client and service code.

---------

Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
  • Loading branch information
2 people authored and vasco-santos committed May 14, 2024
1 parent 797f628 commit ca8e7a3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/upload-client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,15 @@ async function uploadBlockStream(
const bytes = new Uint8Array(await car.arrayBuffer())
// Invoke blob/add and write bytes to write target
const multihash = await Blob.add(conf, bytes, options)
// Should this be raw instead?
const cid = Link.create(carCodec.code, multihash)
let piece
if (pieceHasher) {
const multihashDigest = await pieceHasher.digest(bytes)
/** @type {import('@web3-storage/capabilities/types').PieceLink} */
piece = Link.create(raw.code, multihashDigest)
const content = Link.create(raw.code, multihash)

// Invoke filecoin/offer for data
const result = await Storefront.filecoinOffer(
{
Expand All @@ -149,7 +152,7 @@ async function uploadBlockStream(
with: conf.issuer.did(),
proofs: conf.proofs,
},
cid,
content,
piece,
options
)
Expand Down

0 comments on commit ca8e7a3

Please sign in to comment.