提交 f5e7fe28 作者: Lucas Molas

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: 's avatarLucas Molas <schomatis@gmail.com>
上级 ba733854
......@@ -55,8 +55,6 @@ type Root struct {
dir *Directory
repub *Republisher
dserv ipld.DAGService
}
// 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
root := &Root{
repub: repub,
dserv: ds,
}
pbn, err := ft.FromBytes(node.Data())
......@@ -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
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论