@cryptotaxi247 / kubo / commits / f5ab6a3f5

refactor(commands): cleanup makeDagNodeLinkResults

License: MIT Signed-off-by: hannahhoward <hannah@hannahhoward.net>

hannahhoward committed Nov 19, 2018 at 10:46 UTC f5ab6a3f5ecbb7129f2fea8ccaecc8dbbadbc261
1 file changed +8 -13
core/commands/ls.go
+8 -13
@@ -212,20 +212,15 @@ The JSON output contains type information.
212 }
213
214 func makeDagNodeLinkResults(req *cmds.Request, dagnode ipld.Node) <-chan unixfs.LinkResult {
215 - linkResults := make(chan unixfs.LinkResult)
216 - go func() {
217 - defer close(linkResults)
218 - for _, l := range dagnode.Links() {
219 - select {
220 - case linkResults <- unixfs.LinkResult{
221 - Link: l,
222 - Err: nil,
223 - }:
224 - case <-req.Context.Done():
225 - return
226 - }
215 + links := dagnode.Links()
216 + linkResults := make(chan unixfs.LinkResult, len(links))
217 + defer close(linkResults)
218 + for _, l := range links {
219 + linkResults <- unixfs.LinkResult{
220 + Link: l,
221 + Err: nil,
222 }
228 - }()
223 + }
224 return linkResults
225 }
226