// appendFillLastChild will take in an incomplete trickledag node (uncomplete meaning, not full) and // fill it out to the specified depth with blocks from the given DagBuilderHelper func appendFillLastChild(ufsn *h.UnixfsNode, depth int, layerFill int, db *h.DagBuilderHelper) error { if ufsn.NumChildren() <= db.Maxlinks() { return nil } // Recursive step, grab last child last := ufsn.NumChildren() - 1 lastChild, err := ufsn.GetChild(last, db.GetDagServ()) if err != nil { return err } // Fill out last child (may not be full tree) nchild, err := trickleAppendRec(lastChild, db, depth-1) if err != nil { return err } // Update changed child in parent node ufsn.RemoveChild(last, db) err = ufsn.AddChild(nchild, db) if err != nil { return err } // Partially filled depth layer if layerFill != 0 { for ; layerFill < layerRepeat && !db.Done(); layerFill++ { next := h.NewUnixfsNode() err := fillTrickleRec(db, next, depth) if err != nil { return err } err = ufsn.AddChild(next, db) if err != nil { return err } } } return nil }