Skip to content

Commit

Permalink
mfs: remove DAGService from Root
Browse files Browse the repository at this point in the history
The `Root` structure now explicitly contains a `Directory` (instead of an
`FSNode` interface), use that `Directory`'s `DAGService` instead of its own
`dserv` variable (which was used only once in `closeChild()`). The `DAGService`
in the `Root` and the `Directory` was the same (passed as an argument in the
`NewRoot` initializer function).

This leaves the `Root` structure with only a `Directory` and a `Republisher` and
allows to better rethink its role and whether if those two structures should be
grouped together (and if that group's name should be `Root`).

License: MIT
Signed-off-by: Lucas Molas <schomatis@gmail.com>
  • Loading branch information
schomatis committed Jun 29, 2018
1 parent ba73385 commit f5e7fe2
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions mfs/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ type Root struct {
dir *Directory

repub *Republisher

dserv ipld.DAGService
}

// PubFunc is the function used by the `publish()` method.
Expand All @@ -74,7 +72,6 @@ func NewRoot(parent context.Context, ds ipld.DAGService, node *dag.ProtoNode, pf

root := &Root{
repub: repub,
dserv: ds,
}

pbn, err := ft.FromBytes(node.Data())
Expand Down Expand Up @@ -148,7 +145,7 @@ func (kr *Root) FlushMemFree(ctx context.Context) error {
// closeChild implements the childCloser interface, and signals to the publisher that
// there are changes ready to be published.
func (kr *Root) closeChild(name string, nd ipld.Node, sync bool) error {
err := kr.dserv.Add(context.TODO(), nd)
err := kr.GetDirectory().dserv.Add(context.TODO(), nd)
if err != nil {
return err
}
Expand Down

0 comments on commit f5e7fe2

Please sign in to comment.