Skip to content

Commit

Permalink
fix: upgrade fr32-sha2-256-trunc-254-padded-binary-tree-multihash
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Oct 24, 2023
1 parent f7ee580 commit 762f9f4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/upload-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"build": "tsc --build",
"check": "tsc --build",
"test": "npm-run-all -p -r mock test:all",
"test:all": "run-s test:browser test:node",
"test:all": "run-s test:node test:browser",
"test:node": "hundreds -r html -r text mocha 'test/**/!(*.browser).test.js' -n experimental-vm-modules -n no-warnings",
"test:browser": "playwright-test 'test/**/!(*.node).test.js'",
"mock": "run-p mock:*",
Expand Down 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": "^1.1.4",
"fr32-sha2-256-trunc254-padded-binary-tree-multihash": "^2.0.0",
"ipfs-utils": "^9.0.14",
"multiformats": "^12.1.2",
"p-retry": "^5.1.2",
Expand Down
4 changes: 3 additions & 1 deletion packages/upload-client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export { Store, Upload, UnixFS, CAR }
export * from './sharding.js'

const CONCURRENT_REQUESTS = 3
const PIECE_MULTIHASH_SIZE = PieceHasher.prefix.length + PieceHasher.size
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 @@ -133,6 +133,8 @@ async function uploadBlockStream(conf, blocks, options = {}) {
const digestBytes = new Uint8Array(PIECE_MULTIHASH_SIZE)
hasher.write(bytes)
hasher.digestInto(digestBytes, 0, true)
// TODO: should we?
// hasher.free()
const digest = Digest.decode(digestBytes)
return /** @type {import('@web3-storage/capabilities/types').PieceLink} */ (
Link.create(raw.code, digest)
Expand Down
2 changes: 1 addition & 1 deletion packages/upload-client/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ describe('uploadCAR', () => {
assert.equal(pieceCIDs.length, 1)
assert.equal(
pieceCIDs[0].toString(),
'bafkzcibbammseumg3mjlev5odi5bpcsrp4gg62d7xnx44zkxzvgedq7nxldbc'
'bafkzcibcoibrsisrq3nrfmsxvynduf4kkf7qy33ip65w7ttfk7guyqod5w5mmei'
)
})
})
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 762f9f4

Please sign in to comment.