boxo icon indicating copy to clipboard operation
boxo copied to clipboard

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

Open schomatis opened this issue 7 years ago • 3 comments

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 avatar Oct 15 '18 17:10 schomatis

/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)

schomatis avatar Oct 15 '18 17:10 schomatis

@schomatis 👌

overbool avatar Oct 16 '18 01:10 overbool

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.

Jorropo avatar Jun 26 '23 13:06 Jorropo