Commit 2ea1b470 authored by Lucas Molas's avatar Lucas Molas

helpers: doc and TODOs

parent b1b1f17d
...@@ -175,6 +175,8 @@ func (db *DagBuilderHelper) NewLeafNode(data []byte, fsNodeType pb.Data_DataType ...@@ -175,6 +175,8 @@ func (db *DagBuilderHelper) NewLeafNode(data []byte, fsNodeType pb.Data_DataType
// FillNodeLayer will add datanodes as children to the give node until // FillNodeLayer will add datanodes as children to the give node until
// it is full in this layer or no more data. // it is full in this layer or no more data.
// NOTE: This function creates raw data nodes so it only works
// for the `trickle.Layout`.
func (db *DagBuilderHelper) FillNodeLayer(node *FSNodeOverDag) error { func (db *DagBuilderHelper) FillNodeLayer(node *FSNodeOverDag) error {
// while we have room AND we're not done // while we have room AND we're not done
...@@ -189,6 +191,8 @@ func (db *DagBuilderHelper) FillNodeLayer(node *FSNodeOverDag) error { ...@@ -189,6 +191,8 @@ func (db *DagBuilderHelper) FillNodeLayer(node *FSNodeOverDag) error {
} }
} }
node.Commit() node.Commit()
// TODO: Do we need to commit here? The caller who created the
// `FSNodeOverDag` should be in charge of that.
return nil return nil
} }
...@@ -344,7 +348,7 @@ func (n *FSNodeOverDag) RemoveChild(index int, dbh *DagBuilderHelper) { ...@@ -344,7 +348,7 @@ func (n *FSNodeOverDag) RemoveChild(index int, dbh *DagBuilderHelper) {
// that represents them: the `ft.FSNode` is encoded inside the // that represents them: the `ft.FSNode` is encoded inside the
// `dag.ProtoNode`. // `dag.ProtoNode`.
// //
// TODO: Evaluate making it read-only after committing. // TODO: Make it read-only after committing, allow to commit only once.
func (n *FSNodeOverDag) Commit() (ipld.Node, error) { func (n *FSNodeOverDag) Commit() (ipld.Node, error) {
fileData, err := n.file.GetBytes() fileData, err := n.file.GetBytes()
if err != nil { if err != nil {
...@@ -375,6 +379,8 @@ func (n *FSNodeOverDag) SetFileData(fileData []byte) { ...@@ -375,6 +379,8 @@ func (n *FSNodeOverDag) SetFileData(fileData []byte) {
// GetDagNode fills out the proper formatting for the FSNodeOverDag node // GetDagNode fills out the proper formatting for the FSNodeOverDag node
// inside of a DAG node and returns the dag node. // inside of a DAG node and returns the dag node.
// TODO: Check if we have committed (passed the UnixFS information
// to the DAG layer) before returning this.
func (n *FSNodeOverDag) GetDagNode() (ipld.Node, error) { func (n *FSNodeOverDag) GetDagNode() (ipld.Node, error) {
return n.dag, nil return n.dag, nil
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment