Skip to content

Commit

Permalink
chore: upgrade lib
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Oct 26, 2023
1 parent 651955d commit c14fce3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/upload-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@ucanto/interface": "^9.0.0",
"@ucanto/transport": "^9.0.0",
"@web3-storage/capabilities": "workspace:^",
"fr32-sha2-256-trunc254-padded-binary-tree-multihash": "^2.0.0",
"fr32-sha2-256-trunc254-padded-binary-tree-multihash": "^3.0.0",
"ipfs-utils": "^9.0.14",
"multiformats": "^12.1.2",
"p-retry": "^5.1.2",
Expand Down
10 changes: 6 additions & 4 deletions packages/upload-client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,15 @@ async function uploadBlockStream(conf, blocks, options = {}) {
Store.add(conf, bytes, options),
(async () => {
const hasher = PieceHasher.create()
const digestBytes = new Uint8Array(64)
hasher.write(bytes)
const end = hasher.digestInto(digestBytes, 0, true)
const digest = Digest.decode(digestBytes.subarray(0, end))
const digest = new Uint8Array(hasher.multihashByteLength())
hasher.digestInto(digest, 0, true)
// There's no GC (yet) in WASM so you should free up
// memory manually once you're done.
hasher.free()
const multihashDigest = Digest.decode(digest)
return /** @type {import('@web3-storage/capabilities/types').PieceLink} */ (
Link.create(raw.code, digest)
Link.create(raw.code, multihashDigest)
)
})(),
])
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c14fce3

Please sign in to comment.