• Lucas Molas's avatar
    pbdagreader: use FSNode instead of protobuf structure · c847ff39
    Lucas Molas authored
    Focus on the UnixFS layer and avoid explicit references to protocol buffers
    format (used to serialize objects of that layer). Use the `unixfs.FSNode`
    structure which it abstracts from the `unixfs.pb.Data` format.
    
    Replace `PBDagReader` field `ftpb.Data` with `ft.FSNode`, renaming it to `file`
    (which is the type of UnixFS object represented in the reader) and changing its
    comment removing the "cached" reference, as this structure is not used here as a
    cache (`PBDagReader` doesn't modify the DAG, it's read-only). Also, removed
    unused `ProtoNode` field to avoid confusions, as it would normally be present if
    the `FSNode` was in fact used as a cache of the contents of the `ProtoNode`.
    
    An example of the advantage of shifting the focus from the format to the UnixFS
    layer is dropping the of use `len(pb.Blocksizes)` in favor of the more clear
    `NumChildren()` abstraction.
    
    Added `BlockSize()` accessor.
    
    License: MIT
    Signed-off-by: default avatarLucas Molas <schomatis@gmail.com>
    c847ff39
pbdagreader.go 7.32 KB