ipfs / boxo

A set of reference libraries for building IPFS applications and implementations in Go.
https://github.com/ipfs/boxo#readme
Other
202 stars 87 forks source link

ipld/unixfs/hamt: Encapsulate and document `maxpadlen` logic #388

Open schomatis opened 5 years ago

schomatis commented 5 years ago

Background: https://github.com/ipfs/boxo/issues/387.

To differentiate between nodes of the HAMT directory and nodes that represent an entry in that directory (but that don't belong to it) the links in the DAG layer are being overloaded with hash information of the trie, that is, the link name is being prefixed like AFname (<hash-part><actual-link-name>); so the reader stumbles upon comparisons like len(lnk.Name) == ds.maxpadlen when trying to figure out if this links points to a node of the HAMT directory or a entry node (a value of the in the trie leaf). I don't think this can be changed at this moment since it would be a major API breakage, but the next best thing would be to extract every reference of maxpadlen (and related) to functions that clearly and explicitly tell the reader "we are checking if this link points to a node inside or outside the HAMT directory" and "we want to extract the actual name of the link embedded in lnk.Name attribute".

schomatis commented 5 years ago

/cc @overbool (in case you're interested in continuing the work from https://github.com/ipfs/go-unixfs/pull/30, but feel free to ignore it otherwise)

overbool commented 5 years ago

@schomatis 👌

Jorropo commented 1 year ago

Information about how the max length or bitmap is used to check for sets needs to be present in the unixfs spec too https://github.com/ipfs/specs/pull/331.