Skip to content

Commit

Permalink
chore: address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Oct 25, 2023
1 parent 762f9f4 commit 651955d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/upload-client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export { Store, Upload, UnixFS, CAR }
export * from './sharding.js'

const CONCURRENT_REQUESTS = 3
const PIECE_MULTIHASH_SIZE = PieceHasher.prefix.length + 1 + PieceHasher.size

/**
* Uploads a file to the service and returns the root data CID for the
Expand Down Expand Up @@ -130,12 +129,11 @@ async function uploadBlockStream(conf, blocks, options = {}) {
Store.add(conf, bytes, options),
(async () => {
const hasher = PieceHasher.create()
const digestBytes = new Uint8Array(PIECE_MULTIHASH_SIZE)
const digestBytes = new Uint8Array(64)
hasher.write(bytes)
hasher.digestInto(digestBytes, 0, true)
// TODO: should we?
// hasher.free()
const digest = Digest.decode(digestBytes)
const end = hasher.digestInto(digestBytes, 0, true)
const digest = Digest.decode(digestBytes.subarray(0, end))
hasher.free()
return /** @type {import('@web3-storage/capabilities/types').PieceLink} */ (
Link.create(raw.code, digest)
)
Expand Down

0 comments on commit 651955d

Please sign in to comment.