@@ -352,11 +352,23 @@ func (ds *Shard) EnumLinksAsync(ctx context.Context) <-chan format.LinkResult {
352
352
defer cancel ()
353
353
getLinks := makeAsyncTrieGetLinks (ds .dserv , linkResults )
354
354
cset := cid .NewSet ()
355
- // FIXME: The Shard.cid field which `dag.Walk` depended on is not always
356
- // set on the Shard creation (only when loading from a node). We extract
357
- // the node here then, but this of course means fetching all the shards
358
- // beforehand which is exactly what we don't want. Will look at alternatives
359
- // to make this more standard.
355
+ // FIXME: The `dag.Walk` interface depends on the CID of the root of
356
+ // the DAG being traversed.
357
+ // When this function is called from `io.sizeBelowThreshold` we may
358
+ // not have that available (as the directory has changed and the last
359
+ // CID from which the `io.HAMTDirectory` was loaded from, if any, might
360
+ // be outdated).
361
+ // Ideally we would need to extend the DAG walk function to handle Shards
362
+ // and not IPLD nodes. (See https://github.com/ipfs/go-ipld-format/blob/master/walker.go
363
+ // as an example of a more generic walker that doesn't necessarily depend
364
+ // on IPLD nodes and CIDs, although it may not be the correct choice here.)
365
+ //
366
+ // For the moment, to make the current PR tests pass, we force the Shards
367
+ // to serialize to an IPLD node to extract its CID for the `Walk` API,
368
+ // but this of course means fetching all the shards in the directory
369
+ // beforehand which is exactly what we don't want (defeating the initial
370
+ // purpose of the `io.sizeBelowThreshold` that tries to retrieve as little
371
+ // shards as possible).
360
372
rootNode , err := ds .Node ()
361
373
if err != nil {
362
374
emitResult (ctx , linkResults , format.LinkResult {Link : nil , Err : err })
0 commit comments