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

Provide list iterator interface #51

Closed
wants to merge 1 commit into from

Conversation

hannahhoward
Copy link
Collaborator

Goals

Allows a UnixFS dirs and HAMT dirs to be interated as a list. This works the same as the MapIterator interface but allows accessing the TSize property.

Note when iterating a HAMT, only leaf nodes are returned, and the Name field is shortened to not include the hamt prefix

@@ -256,7 +256,14 @@ func (itr *_UnixFSShardedDir__ListItr) Done() bool {
// can be expected that itr.Next will be called node.Length times
// before itr.Done becomes true.
func (n UnixFSHAMTShard) ListIterator() ipld.ListIterator {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we want to do this as a list -

The IPLD node interface for a directory will be of kind Map, so by the IPLD contract i would expect that asking for a list iterator returns `nil.

A non-ipld interface + method might be clearer for accessing this functionality.

@willscott
Copy link
Collaborator

I'm proposing that #60 is a potentially nicer way to expose the functionality that this.

this is mis-using the ipld interface a bit more, and while i don't expect problems from it, i'm a little sketched-out by the overloading.

@rvagg
Copy link
Member

rvagg commented Aug 25, 2023

I think this is covered by #60 now

@rvagg rvagg closed this Aug 25, 2023
@rvagg rvagg deleted the feat/list-iterator-for-dirs branch August 25, 2023 23:48
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