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

importer: remove UnixfsNode from the balanced builder #5118

Merged
merged 1 commit into from
Jul 16, 2018
Merged

importer: remove UnixfsNode from the balanced builder #5118

merged 1 commit into from
Jul 16, 2018

Commits on Jul 16, 2018

  1. importer: remove UnixfsNode from the balanced builder

    The `UnixfsNode` structure has multiple pointers to many (non-complementary)
    mutually exclusive node types, only some of them are active (not-`nil`) at a
    given time in the code path which made the code too convoluted. Specifically,
    the most important distinction between node types was being hidden: leaf nodes
    vs internal (non-leaf) nodes.
    
    Remove entirely the use of `UnixfsNode` from the `balanced` package replacing it
    in turn with the newly created `FSNodeOverDag` structure that represents the
    UnixFS node encoded inside the DAG node, primarily used for internal node
    representations. Leaf nodes are handled exclusively in the `NewLeafDataNode`
    encapsulating its multiple representations (that we're previously exposed in
    `UnixfsNode` as conflicting pointers).
    
    The `builder.go` file has been completely rewritten, although the basic DAG
    creation algorithm has been preserved (extending a full DAG by creating a new
    root and linking the old one as its child), the most significant modification
    has been in the loop of `Layout` that now only handles internal nodes (i.e.,
    nodes with `depth` bigger than zero) to be able to adapt `fillNodeRec` to only
    that scenario (avoiding the replace logic of the zero `depth` case with the
    defective `Set` function, now removed). The `fillNodeRec` now explicitly returns
    the `ipld.Node` and the size of the file data it's storing to propagate it
    upwards into the DAG.
    
    The `DagBuilderHelper` was heavily extended to incorporate `ipld.Node` functions
    that would replace the `UnixfsNode` ones used by the balanced builder:
    `NewLeafNode()`, `NewLeafDataNode()` and `AddNodeAndClose()`. Also, the
    `ProcessFileStore` function was incorporated to encapsulate all the logic
    related to the Filestore support which was scattered throughout the builder
    logic, the `offset` that was being passed through most functions is now a part
    of the `DagBuilderHelper`.
    
    This has turned out to be a rather big commit, it should have been split into
    more smaller and logically cohesive commits, but the `UnixfsNode` was too
    entangled inside the logic and that would have required a progressive
    modification of the `UnixfsNode` structure as well, which wasn't possible as it
    is still being used by the balanced builder (the same reason why most of the
    `UnixfsNode`-related functions cannot yet be removed, leaving the `helpers.go`
    file mostly untouched).
    
    License: MIT
    Signed-off-by: Lucas Molas <schomatis@gmail.com>
    schomatis committed Jul 16, 2018
    Configuration menu
    Copy the full SHA
    474b77a View commit details
    Browse the repository at this point in the history