Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: compute piece CID in client #925

Merged
merged 4 commits into from
Sep 15, 2023
Merged

feat: compute piece CID in client #925

merged 4 commits into from
Sep 15, 2023

Conversation

alanshaw
Copy link
Member

@alanshaw alanshaw commented Sep 14, 2023

This PR alters the client to compute piece CIDs for each shard, and exposes it via the CARMetadata provided to the onShardStored callback.

I removed the ShardStoringStream. In hindsight, the only real utility it was providing was parallelizing the calls to Store.add(...). I swapped in a parallel transform stream that allows us to do the same thing, but also concurrently calculate the piece CID of the shard.

Note: the client does not yet do anything with the piece CID, but in theory it will be trivial to collect them and then send a bunch of invocations to trigger filecoin.

assert(service.upload.add.called)
assert.equal(service.upload.add.callCount, 1)
assert.equal(pieceCIDs.length, 1)
assert.equal(pieceCIDs[0].toString(), 'bafkzcibbammseumg3mjlev5odi5bpcsrp4gg62d7xnx44zkxzvgedq7nxldbc')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this look right to you guys? I was expecting baga... but then I think that is v1.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gozala
Copy link
Contributor

Gozala commented Sep 14, 2023

I think we should wasm version as it's noticeably faster, but I'm still struggling to find a way to make it bundler friendly

Copy link
Contributor

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
We can swap to https://github.com/web3-storage/fr32-sha2-256-trunc254-padded-binary-tree-multihash/ + hookup this to invocation as follow up PRs

@alanshaw alanshaw merged commit 2297f01 into main Sep 15, 2023
15 checks passed
@alanshaw alanshaw deleted the feat/commPute branch September 15, 2023 08:41
alanshaw pushed a commit that referenced this pull request Sep 15, 2023
🤖 I have created a release *beep* *boop*
---


##
[9.3.0](upload-client-v9.2.0...upload-client-v9.3.0)
(2023-09-15)


### Features

* compute piece CID in client
([#925](#925))
([2297f01](2297f01))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants