rename root to last
Jeromy committed
May 29, 2015 at 13:33 UTC
a0aa07e39fcc9cbdd3ca19ac78e9ae1e1abce731
2 files changed
+7
-6
importer/helpers/dagbuilder.go
+4
-3
@@ -6,9 +6,10 @@ import (
6
)
7
8
// NodeCB is callback function for dag generation
9
-// the `root` flag signifies whether or not this is
10
-// the root of a dag.
11
-type NodeCB func(node *dag.Node, root bool) error
9
+// the `last` flag signifies whether or not this is the last
10
+// (top-most root) node being added. useful for things like
11
+// only pinning the first node recursively.
12
+type NodeCB func(node *dag.Node, last bool) error
13
14
var nilFunc NodeCB = func(_ *dag.Node, _ bool) error { return nil }
15
importer/importer.go
+3
-3
@@ -66,13 +66,13 @@ func BuildTrickleDagFromReader(r io.Reader, ds dag.DAGService, spl chunk.BlockSp
66
}
67
68
func BasicPinnerCB(p pin.ManualPinner) h.NodeCB {
69
- return func(n *dag.Node, root bool) error {
69
+ return func(n *dag.Node, last bool) error {
70
k, err := n.Key()
71
if err != nil {
72
return err
73
}
74
75
- if root {
75
+ if last {
76
p.PinWithMode(k, pin.Recursive)
77
return p.Flush()
78
} else {
@@ -83,7 +83,7 @@ func BasicPinnerCB(p pin.ManualPinner) h.NodeCB {
83
}
84
85
func PinIndirectCB(p pin.ManualPinner) h.NodeCB {
86
- return func(n *dag.Node, root bool) error {
86
+ return func(n *dag.Node, last bool) error {
87
k, err := n.Key()
88
if err != nil {
89
return err