1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-29 09:34:03 +08:00

rename root to last

This commit is contained in:
Jeromy
2015-05-29 13:33:45 -07:00
parent 38479ff1d3
commit a0aa07e39f
2 changed files with 7 additions and 6 deletions

View File

@ -6,9 +6,10 @@ import (
) )
// NodeCB is callback function for dag generation // NodeCB is callback function for dag generation
// the `root` flag signifies whether or not this is // the `last` flag signifies whether or not this is the last
// the root of a dag. // (top-most root) node being added. useful for things like
type NodeCB func(node *dag.Node, root bool) error // only pinning the first node recursively.
type NodeCB func(node *dag.Node, last bool) error
var nilFunc NodeCB = func(_ *dag.Node, _ bool) error { return nil } var nilFunc NodeCB = func(_ *dag.Node, _ bool) error { return nil }

View File

@ -66,13 +66,13 @@ func BuildTrickleDagFromReader(r io.Reader, ds dag.DAGService, spl chunk.BlockSp
} }
func BasicPinnerCB(p pin.ManualPinner) h.NodeCB { func BasicPinnerCB(p pin.ManualPinner) h.NodeCB {
return func(n *dag.Node, root bool) error { return func(n *dag.Node, last bool) error {
k, err := n.Key() k, err := n.Key()
if err != nil { if err != nil {
return err return err
} }
if root { if last {
p.PinWithMode(k, pin.Recursive) p.PinWithMode(k, pin.Recursive)
return p.Flush() return p.Flush()
} else { } else {
@ -83,7 +83,7 @@ func BasicPinnerCB(p pin.ManualPinner) h.NodeCB {
} }
func PinIndirectCB(p pin.ManualPinner) h.NodeCB { func PinIndirectCB(p pin.ManualPinner) h.NodeCB {
return func(n *dag.Node, root bool) error { return func(n *dag.Node, last bool) error {
k, err := n.Key() k, err := n.Key()
if err != nil { if err != nil {
return err return err