refactor(commands): cleanup makeDagNodeLinkResults

License: MIT
Signed-off-by: hannahhoward <hannah@hannahhoward.net>
This commit is contained in:
hannahhoward 2018-11-19 10:46:09 -08:00
parent b0dc73c45f
commit f5ab6a3f5e

View File

@ -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
}