mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-26 15:42:21 +08:00
Merge pull request #4885 from ipfs/fix/visit-when-asked
only visit nodes in EnumerateChildrenAsync when asked
This commit is contained in:
@ -319,17 +319,17 @@ func EnumerateChildrenAsync(ctx context.Context, getLinks GetLinks, c *cid.Cid,
|
|||||||
for i := 0; i < FetchGraphConcurrency; i++ {
|
for i := 0; i < FetchGraphConcurrency; i++ {
|
||||||
go func() {
|
go func() {
|
||||||
for ic := range feed {
|
for ic := range feed {
|
||||||
links, err := getLinks(ctx, ic)
|
|
||||||
if err != nil {
|
|
||||||
errChan <- err
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setlk.Lock()
|
setlk.Lock()
|
||||||
unseen := visit(ic)
|
shouldVisit := visit(ic)
|
||||||
setlk.Unlock()
|
setlk.Unlock()
|
||||||
|
|
||||||
if unseen {
|
if shouldVisit {
|
||||||
|
links, err := getLinks(ctx, ic)
|
||||||
|
if err != nil {
|
||||||
|
errChan <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case out <- links:
|
case out <- links:
|
||||||
case <-fetchersCtx.Done():
|
case <-fetchersCtx.Done():
|
||||||
|
Reference in New Issue
Block a user