From ca8e7a34d16afd877ac0e3098f48497c14508d40 Mon Sep 17 00:00:00 2001 From: Andrew Gillis Date: Tue, 14 May 2024 04:57:10 -0700 Subject: [PATCH] feat: move blob index logic from upload-api to blob-index lib (#1434) 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 --- packages/upload-client/src/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/upload-client/src/index.js b/packages/upload-client/src/index.js index 7c8ab1e8d..ac714d5d5 100644 --- a/packages/upload-client/src/index.js +++ b/packages/upload-client/src/index.js @@ -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( { @@ -149,7 +152,7 @@ async function uploadBlockStream( with: conf.issuer.did(), proofs: conf.proofs, }, - cid, + content, piece, options )