本文整理匯總了Golang中github.com/djbarber/ipfs-hack/importer/helpers.DagBuilderHelper.FillNodeWithData方法的典型用法代碼示例。如果您正苦於以下問題:Golang DagBuilderHelper.FillNodeWithData方法的具體用法?Golang DagBuilderHelper.FillNodeWithData怎麽用?Golang DagBuilderHelper.FillNodeWithData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/djbarber/ipfs-hack/importer/helpers.DagBuilderHelper
的用法示例。
在下文中一共展示了DagBuilderHelper.FillNodeWithData方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: fillNodeRec
// fillNodeRec will fill the given node with data from the dagBuilders input
// source down to an indirection depth as specified by 'depth'
// it returns the total dataSize of the node, and a potential error
//
// warning: **children** pinned indirectly, but input node IS NOT pinned.
func fillNodeRec(db *h.DagBuilderHelper, node *h.UnixfsNode, depth int) error {
if depth < 0 {
return errors.New("attempt to fillNode at depth < 0")
}
// Base case
if depth <= 0 { // catch accidental -1's in case error above is removed.
return db.FillNodeWithData(node)
}
// while we have room AND we're not done
for node.NumChildren() < db.Maxlinks() && !db.Done() {
child := h.NewUnixfsNode()
if err := fillNodeRec(db, child, depth-1); err != nil {
return err
}
if err := node.AddChild(child, db); err != nil {
return err
}
}
return nil
}