Skip to content

Commit

Permalink
Merge pull request #4885 from ipfs/fix/visit-when-asked
Browse files Browse the repository at this point in the history
only visit nodes in EnumerateChildrenAsync when asked
  • Loading branch information
whyrusleeping authored Mar 29, 2018
2 parents 5770bf8 + 08388e7 commit d82bf5f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions merkledag/merkledag.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,17 +319,17 @@ func EnumerateChildrenAsync(ctx context.Context, getLinks GetLinks, c *cid.Cid,
for i := 0; i < FetchGraphConcurrency; i++ {
go func() {
for ic := range feed {
links, err := getLinks(ctx, ic)
if err != nil {
errChan <- err
return
}

setlk.Lock()
unseen := visit(ic)
shouldVisit := visit(ic)
setlk.Unlock()

if unseen {
if shouldVisit {
links, err := getLinks(ctx, ic)
if err != nil {
errChan <- err
return
}

select {
case out <- links:
case <-fetchersCtx.Done():
Expand Down

0 comments on commit d82bf5f

Please sign in to comment.