Skip to content

Commit

Permalink
refactor(commands): cleanup makeDagNodeLinkResults
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: hannahhoward <hannah@hannahhoward.net>
  • Loading branch information
hannahhoward committed Nov 20, 2018
1 parent b0dc73c commit f5ab6a3
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions core/commands/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,15 @@ The JSON output contains type information.
}

func makeDagNodeLinkResults(req *cmds.Request, dagnode ipld.Node) <-chan unixfs.LinkResult {
linkResults := make(chan unixfs.LinkResult)
go func() {
defer close(linkResults)
for _, l := range dagnode.Links() {
select {
case linkResults <- unixfs.LinkResult{
Link: l,
Err: nil,
}:
case <-req.Context.Done():
return
}
links := dagnode.Links()
linkResults := make(chan unixfs.LinkResult, len(links))
defer close(linkResults)
for _, l := range links {
linkResults <- unixfs.LinkResult{
Link: l,
Err: nil,
}
}()
}
return linkResults
}

Expand Down

0 comments on commit f5ab6a3

Please sign in to comment.