Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Conversation

schomatis
Copy link
Contributor

@schomatis schomatis commented Jul 30, 2021

Extracted from review in #94 (comment).

This ended up being a much cleaner patch than I originally anticipated. Since go-merkledag provides an API to add both nodes and links we now add links directly to the node through AddRawLink while maintaining the current AddChild API (not needing to expand it with a public variant and keeping the plumbing addLinkChild function private) that now converts itself the node to a link (a conversion that would otherwise happen inside the replaced AddNodeLink call).

@schomatis schomatis self-assigned this Jul 30, 2021
@schomatis schomatis mentioned this pull request Jul 30, 2021
4 tasks
@schomatis schomatis force-pushed the schomatis/directory/sharding/switchToBasic-optimization-1 branch from f633ab3 to 72c69ed Compare August 2, 2021 22:15
@schomatis schomatis marked this pull request as ready for review August 2, 2021 22:22
Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

LGTM.

(feel free to ignore my one comment, it doesn't really make anything any better)


// addLinkChild adds the link as an entry to this directory under the given
// name. Plumbing function for the AddChild API.
func (d *BasicDirectory) addLinkChild(ctx context.Context, name string, link *ipld.Link) error {
Copy link
Member

Choose a reason for hiding this comment

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

nit: the name seems redundant given that ipld.Link already includes a name.

(I mean, ideally we could just use a CID... but we need the size because dagpb).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My first version was actually just the link argument with the name packed inside but looking at how we manipulate links in go-merkledag it seemed like the idiomatic way to go was to maniuplate that separately. Even internally here in go-unixfs we handle the name separately.

I totally agree with you and the current way seems a bit counter-intuitive to me so happy to revert to my previous version.

Copy link
Member

Choose a reason for hiding this comment

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

No, leave it. Ideally we'd just get rid of that type entirely but that's work for another day.

@schomatis schomatis merged commit 7d338e3 into schomatis/directory/unsharding Aug 3, 2021
@schomatis schomatis deleted the schomatis/directory/sharding/switchToBasic-optimization-1 branch August 3, 2021 16:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants