mfs: remove `DAGService` from `Root`
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>
Lucas Molas committed
Jun 29, 2018 at 12:04 UTC
f5e7fe28dde7c082e2325276833321671a0f3001
1 file changed
+1
-4
mfs/system.go
+1
-4
@@ -55,8 +55,6 @@ type Root struct {
55
dir *Directory
56
57
repub *Republisher
58
-
59
- dserv ipld.DAGService
58
}
59
60
// PubFunc is the function used by the `publish()` method.
@@ -74,7 +72,6 @@ func NewRoot(parent context.Context, ds ipld.DAGService, node *dag.ProtoNode, pf
72
73
root := &Root{
74
repub: repub,
77
- dserv: ds,
75
}
76
77
pbn, err := ft.FromBytes(node.Data())
@@ -148,7 +145,7 @@ func (kr *Root) FlushMemFree(ctx context.Context) error {
145
// closeChild implements the childCloser interface, and signals to the publisher that
146
// there are changes ready to be published.
147
func (kr *Root) closeChild(name string, nd ipld.Node, sync bool) error {
151
- err := kr.dserv.Add(context.TODO(), nd)
148
+ err := kr.GetDirectory().dserv.Add(context.TODO(), nd)
149
if err != nil {
150
return err
151
}