diff --git a/importer/helpers/dagbuilder.go b/importer/helpers/dagbuilder.go index 1504205d6781a1e37ad4b77298861fbcf68747dc..e6c7e721d3132e8ebdd2673eb6ad0648c572a630 100644 --- a/importer/helpers/dagbuilder.go +++ b/importer/helpers/dagbuilder.go @@ -6,9 +6,10 @@ import ( ) // NodeCB is callback function for dag generation -// the `root` flag signifies whether or not this is -// the root of a dag. -type NodeCB func(node *dag.Node, root bool) error +// the `last` flag signifies whether or not this is the last +// (top-most root) node being added. useful for things like +// 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 } diff --git a/importer/importer.go b/importer/importer.go index c3d9eea6e166ff1883c63af486e0ebe87303709e..f499b190a4f85e6224aeb06f29c55b814d272cf7 100644 --- a/importer/importer.go +++ b/importer/importer.go @@ -66,13 +66,13 @@ func BuildTrickleDagFromReader(r io.Reader, ds dag.DAGService, spl chunk.BlockSp } 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() if err != nil { return err } - if root { + if last { p.PinWithMode(k, pin.Recursive) return p.Flush() } else { @@ -83,7 +83,7 @@ func BasicPinnerCB(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() if err != nil { return err