@@ -60,7 +60,7 @@ func (n *dagService) AddMany(ctx context.Context, nds []ipld.Node) error {
60
60
}
61
61
62
62
// Get retrieves a node from the dagService, fetching the block in the BlockService
63
- func (n * dagService ) Get (ctx context.Context , c * cid.Cid ) (ipld.Node , error ) {
63
+ func (n * dagService ) Get (ctx context.Context , c cid.Cid ) (ipld.Node , error ) {
64
64
if n == nil {
65
65
return nil , fmt .Errorf ("dagService is nil" )
66
66
}
@@ -81,7 +81,7 @@ func (n *dagService) Get(ctx context.Context, c *cid.Cid) (ipld.Node, error) {
81
81
82
82
// GetLinks return the links for the node, the node doesn't necessarily have
83
83
// to exist locally.
84
- func (n * dagService ) GetLinks (ctx context.Context , c * cid.Cid ) ([]* ipld.Link , error ) {
84
+ func (n * dagService ) GetLinks (ctx context.Context , c cid.Cid ) ([]* ipld.Link , error ) {
85
85
if c .Type () == cid .Raw {
86
86
return nil , nil
87
87
}
@@ -92,7 +92,7 @@ func (n *dagService) GetLinks(ctx context.Context, c *cid.Cid) ([]*ipld.Link, er
92
92
return node .Links (), nil
93
93
}
94
94
95
- func (n * dagService ) Remove (ctx context.Context , c * cid.Cid ) error {
95
+ func (n * dagService ) Remove (ctx context.Context , c cid.Cid ) error {
96
96
return n .Blocks .DeleteBlock (c )
97
97
}
98
98
@@ -101,7 +101,7 @@ func (n *dagService) Remove(ctx context.Context, c *cid.Cid) error {
101
101
//
102
102
// This operation is not atomic. If it returns an error, some nodes may or may
103
103
// not have been removed.
104
- func (n * dagService ) RemoveMany (ctx context.Context , cids []* cid.Cid ) error {
104
+ func (n * dagService ) RemoveMany (ctx context.Context , cids []cid.Cid ) error {
105
105
// TODO(#4608): make this batch all the way down.
106
106
for _ , c := range cids {
107
107
if err := n .Blocks .DeleteBlock (c ); err != nil {
@@ -115,7 +115,7 @@ func (n *dagService) RemoveMany(ctx context.Context, cids []*cid.Cid) error {
115
115
// the node, bypassing the LinkService. If the node does not exist
116
116
// locally (and can not be retrieved) an error will be returned.
117
117
func GetLinksDirect (serv ipld.NodeGetter ) GetLinks {
118
- return func (ctx context.Context , c * cid.Cid ) ([]* ipld.Link , error ) {
118
+ return func (ctx context.Context , c cid.Cid ) ([]* ipld.Link , error ) {
119
119
nd , err := serv .Get (ctx , c )
120
120
if err != nil {
121
121
if err == bserv .ErrNotFound {
@@ -132,7 +132,7 @@ type sesGetter struct {
132
132
}
133
133
134
134
// Get gets a single node from the DAG.
135
- func (sg * sesGetter ) Get (ctx context.Context , c * cid.Cid ) (ipld.Node , error ) {
135
+ func (sg * sesGetter ) Get (ctx context.Context , c cid.Cid ) (ipld.Node , error ) {
136
136
blk , err := sg .bs .GetBlock (ctx , c )
137
137
switch err {
138
138
case bserv .ErrNotFound :
@@ -147,7 +147,7 @@ func (sg *sesGetter) Get(ctx context.Context, c *cid.Cid) (ipld.Node, error) {
147
147
}
148
148
149
149
// GetMany gets many nodes at once, batching the request if possible.
150
- func (sg * sesGetter ) GetMany (ctx context.Context , keys []* cid.Cid ) <- chan * ipld.NodeOption {
150
+ func (sg * sesGetter ) GetMany (ctx context.Context , keys []cid.Cid ) <- chan * ipld.NodeOption {
151
151
return getNodesFromBG (ctx , sg .bs , keys )
152
152
}
153
153
@@ -157,15 +157,15 @@ func (n *dagService) Session(ctx context.Context) ipld.NodeGetter {
157
157
}
158
158
159
159
// FetchGraph fetches all nodes that are children of the given node
160
- func FetchGraph (ctx context.Context , root * cid.Cid , serv ipld.DAGService ) error {
160
+ func FetchGraph (ctx context.Context , root cid.Cid , serv ipld.DAGService ) error {
161
161
return FetchGraphWithDepthLimit (ctx , root , - 1 , serv )
162
162
}
163
163
164
164
// FetchGraphWithDepthLimit fetches all nodes that are children to the given
165
165
// node down to the given depth. maxDetph=0 means "only fetch root",
166
166
// maxDepth=1 means "fetch root and its direct children" and so on...
167
167
// maxDepth=-1 means unlimited.
168
- func FetchGraphWithDepthLimit (ctx context.Context , root * cid.Cid , depthLim int , serv ipld.DAGService ) error {
168
+ func FetchGraphWithDepthLimit (ctx context.Context , root cid.Cid , depthLim int , serv ipld.DAGService ) error {
169
169
var ng ipld.NodeGetter = serv
170
170
ds , ok := serv .(* dagService )
171
171
if ok {
@@ -181,7 +181,7 @@ func FetchGraphWithDepthLimit(ctx context.Context, root *cid.Cid, depthLim int,
181
181
// to explore deeper than before).
182
182
// depthLim = -1 means we only return true if the element is not in the
183
183
// set.
184
- visit := func (c * cid.Cid , depth int ) bool {
184
+ visit := func (c cid.Cid , depth int ) bool {
185
185
key := string (c .Bytes ())
186
186
oldDepth , ok := set [key ]
187
187
@@ -201,7 +201,7 @@ func FetchGraphWithDepthLimit(ctx context.Context, root *cid.Cid, depthLim int,
201
201
return EnumerateChildrenAsyncDepth (ctx , GetLinksDirect (ng ), root , 0 , visit )
202
202
}
203
203
204
- visitProgress := func (c * cid.Cid , depth int ) bool {
204
+ visitProgress := func (c cid.Cid , depth int ) bool {
205
205
if visit (c , depth ) {
206
206
v .Increment ()
207
207
return true
@@ -216,11 +216,11 @@ func FetchGraphWithDepthLimit(ctx context.Context, root *cid.Cid, depthLim int,
216
216
// This method may not return all requested nodes (and may or may not return an
217
217
// error indicating that it failed to do so. It is up to the caller to verify
218
218
// that it received all nodes.
219
- func (n * dagService ) GetMany (ctx context.Context , keys []* cid.Cid ) <- chan * ipld.NodeOption {
219
+ func (n * dagService ) GetMany (ctx context.Context , keys []cid.Cid ) <- chan * ipld.NodeOption {
220
220
return getNodesFromBG (ctx , n .Blocks , keys )
221
221
}
222
222
223
- func dedupKeys (keys []* cid.Cid ) []* cid.Cid {
223
+ func dedupKeys (keys []cid.Cid ) []cid.Cid {
224
224
set := cid .NewSet ()
225
225
for _ , c := range keys {
226
226
set .Add (c )
@@ -231,7 +231,7 @@ func dedupKeys(keys []*cid.Cid) []*cid.Cid {
231
231
return set .Keys ()
232
232
}
233
233
234
- func getNodesFromBG (ctx context.Context , bs bserv.BlockGetter , keys []* cid.Cid ) <- chan * ipld.NodeOption {
234
+ func getNodesFromBG (ctx context.Context , bs bserv.BlockGetter , keys []cid.Cid ) <- chan * ipld.NodeOption {
235
235
keys = dedupKeys (keys )
236
236
237
237
out := make (chan * ipld.NodeOption , len (keys ))
@@ -270,23 +270,23 @@ func getNodesFromBG(ctx context.Context, bs bserv.BlockGetter, keys []*cid.Cid)
270
270
271
271
// GetLinks is the type of function passed to the EnumerateChildren function(s)
272
272
// for getting the children of an IPLD node.
273
- type GetLinks func (context.Context , * cid.Cid ) ([]* ipld.Link , error )
273
+ type GetLinks func (context.Context , cid.Cid ) ([]* ipld.Link , error )
274
274
275
275
// GetLinksWithDAG returns a GetLinks function that tries to use the given
276
276
// NodeGetter as a LinkGetter to get the children of a given IPLD node. This may
277
277
// allow us to traverse the DAG without actually loading and parsing the node in
278
278
// question (if we already have the links cached).
279
279
func GetLinksWithDAG (ng ipld.NodeGetter ) GetLinks {
280
- return func (ctx context.Context , c * cid.Cid ) ([]* ipld.Link , error ) {
280
+ return func (ctx context.Context , c cid.Cid ) ([]* ipld.Link , error ) {
281
281
return ipld .GetLinks (ctx , ng , c )
282
282
}
283
283
}
284
284
285
285
// EnumerateChildren will walk the dag below the given root node and add all
286
286
// unseen children to the passed in set.
287
287
// TODO: parallelize to avoid disk latency perf hits?
288
- func EnumerateChildren (ctx context.Context , getLinks GetLinks , root * cid.Cid , visit func (* cid.Cid ) bool ) error {
289
- visitDepth := func (c * cid.Cid , depth int ) bool {
288
+ func EnumerateChildren (ctx context.Context , getLinks GetLinks , root cid.Cid , visit func (cid.Cid ) bool ) error {
289
+ visitDepth := func (c cid.Cid , depth int ) bool {
290
290
return visit (c )
291
291
}
292
292
@@ -296,7 +296,7 @@ func EnumerateChildren(ctx context.Context, getLinks GetLinks, root *cid.Cid, vi
296
296
// EnumerateChildrenDepth walks the dag below the given root and passes the
297
297
// current depth to a given visit function. The visit function can be used to
298
298
// limit DAG exploration.
299
- func EnumerateChildrenDepth (ctx context.Context , getLinks GetLinks , root * cid.Cid , depth int , visit func (* cid.Cid , int ) bool ) error {
299
+ func EnumerateChildrenDepth (ctx context.Context , getLinks GetLinks , root cid.Cid , depth int , visit func (cid.Cid , int ) bool ) error {
300
300
links , err := getLinks (ctx , root )
301
301
if err != nil {
302
302
return err
@@ -348,8 +348,8 @@ var FetchGraphConcurrency = 8
348
348
// fetches children in parallel.
349
349
//
350
350
// NOTE: It *does not* make multiple concurrent calls to the passed `visit` function.
351
- func EnumerateChildrenAsync (ctx context.Context , getLinks GetLinks , c * cid.Cid , visit func (* cid.Cid ) bool ) error {
352
- visitDepth := func (c * cid.Cid , depth int ) bool {
351
+ func EnumerateChildrenAsync (ctx context.Context , getLinks GetLinks , c cid.Cid , visit func (cid.Cid ) bool ) error {
352
+ visitDepth := func (c cid.Cid , depth int ) bool {
353
353
return visit (c )
354
354
}
355
355
@@ -360,9 +360,9 @@ func EnumerateChildrenAsync(ctx context.Context, getLinks GetLinks, c *cid.Cid,
360
360
// that it fetches children in parallel (down to a maximum depth in the graph).
361
361
//
362
362
// NOTE: It *does not* make multiple concurrent calls to the passed `visit` function.
363
- func EnumerateChildrenAsyncDepth (ctx context.Context , getLinks GetLinks , c * cid.Cid , startDepth int , visit func (* cid.Cid , int ) bool ) error {
363
+ func EnumerateChildrenAsyncDepth (ctx context.Context , getLinks GetLinks , c cid.Cid , startDepth int , visit func (cid.Cid , int ) bool ) error {
364
364
type cidDepth struct {
365
- cid * cid.Cid
365
+ cid cid.Cid
366
366
depth int
367
367
}
368
368
0 commit comments