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

feature: implement hamt writing #603

Merged
merged 9 commits into from
Dec 16, 2022
Merged

feature: implement hamt writing #603

merged 9 commits into from
Dec 16, 2022

Conversation

rklaehn
Copy link
Contributor

@rklaehn rklaehn commented Dec 15, 2022

This provides basic hamt writing. You can add a big directory, get it back, and look at it from the gateway.

Go-ipfs interop has been tried for one large dir and works.

I have manually added both large non hamt dirs and large hamt dirs and looked at them in the gw.

image

The real fix is of course to make this a streaming request... But that will
come later.
# Conflicts:
#	iroh-unixfs/src/builder.rs
stream! {
while let Some(block) = blocks.next().await {
let block = block?;
let block_size = block.data().len() as u64;
let block_size = block.data().len() as u64 + block.links().len() as u64 * 128;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dignifiedquire this is the temp fix for not having blocks that are too large, until we implement https://github.com/n0-computer/iroh/issues/594

@rklaehn
Copy link
Contributor Author

rklaehn commented Dec 16, 2022

Update: go-ipfs interop does work, at least for my big test dir:

image

@rklaehn rklaehn requested a review from flub December 16, 2022 08:43
I could not find an actual collision, so I just added twice the exact same
name for a test, which currently has the same effect.
pub fn encode<'a>(self) -> LocalBoxStream<'a, Result<Block>> {
match self {
Self::Branch(tree) => {
async_stream::try_stream! {
Copy link
Contributor

Choose a reason for hiding this comment

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

This reads quite sane, great job.

@rklaehn rklaehn merged commit 5f2d87f into main Dec 16, 2022
@rklaehn rklaehn deleted the hamt-writing-2 branch December 16, 2022 15:10
ppodolsky pushed a commit to izihawa/iroh that referenced this pull request Dec 28, 2022
* feature: implement hamt writing

* fix: consider link size when sending data

The real fix is of course to make this a streaming request... But that will
come later.

* test: add test for a truly large directory

* refactor: cleanup

* refactor: properly handle hash collisions

I could not find an actual collision, so I just added twice the exact same
name for a test, which currently has the same effect.
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.

None yet

2 participants