Commit 183a92b6 authored by Bamvor Zhang's avatar Bamvor Zhang Committed by Lucas Molas

dag: remove the old FillNodeLayer

License: MIT
Signed-off-by: default avatarBamvor Zhang <jian.zhang@ipfsbit.com>
parent 032dcd44
......@@ -228,26 +228,8 @@ func (db *DagBuilderHelper) newUnixfsBlock() *UnixfsNode {
}
// FillNodeLayer will add datanodes as children to the give node until
// at most db.indirSize nodes are added.
func (db *DagBuilderHelper) FillNodeLayer(node *UnixfsNode) error {
// while we have room AND we're not done
for node.NumChildren() < db.maxlinks && !db.Done() {
child, err := db.GetNextDataNode()
if err != nil {
return err
}
if err := node.AddChild(child, db); err != nil {
return err
}
}
return nil
}
// FillFSNodeLayer do the same thing as FillNodeLayer.
func (db *DagBuilderHelper) FillFSNodeLayer(node *FSNodeOverDag) error {
// it is full in this layer or no more data.
func (db *DagBuilderHelper) FillNodeLayer(node *FSNodeOverDag) error {
// while we have room AND we're not done
for node.NumChildren() < db.maxlinks && !db.Done() {
......
......@@ -51,7 +51,7 @@ func Layout(db *h.DagBuilderHelper) (ipld.Node, error) {
// (where the DAG builder will signal the end of data to end the function).
func fillTrickleRec(db *h.DagBuilderHelper, node *h.FSNodeOverDag, maxDepth int) (filledNode ipld.Node, nodeFileSize uint64, err error) {
// Always do this, even in the base case
if err := db.FillFSNodeLayer(node); err != nil {
if err := db.FillNodeLayer(node); err != nil {
return nil, 0, err
}
......@@ -105,7 +105,7 @@ func Append(ctx context.Context, basen ipld.Node, db *h.DagBuilderHelper) (out i
n, layerProgress := trickleDepthInfo(fsn, db.Maxlinks())
if n == 0 {
// If direct blocks not filled...
if err := db.FillFSNodeLayer(fsn); err != nil {
if err := db.FillNodeLayer(fsn); err != nil {
return nil, err
}
......@@ -204,7 +204,7 @@ func appendRec(ctx context.Context, fsn *h.FSNodeOverDag, db *h.DagBuilderHelper
n, layerProgress := trickleDepthInfo(fsn, db.Maxlinks())
if n == 0 {
// If direct blocks not filled...
if err := db.FillFSNodeLayer(fsn); err != nil {
if err := db.FillNodeLayer(fsn); err != nil {
return nil, 0, err
}
n++
......
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