提交 f5ab6a3f 作者: hannahhoward

refactor(commands): cleanup makeDagNodeLinkResults

License: MIT
Signed-off-by: 's avatarhannahhoward <hannah@hannahhoward.net>
上级 b0dc73c4
...@@ -212,20 +212,15 @@ The JSON output contains type information. ...@@ -212,20 +212,15 @@ The JSON output contains type information.
} }
func makeDagNodeLinkResults(req *cmds.Request, dagnode ipld.Node) <-chan unixfs.LinkResult { func makeDagNodeLinkResults(req *cmds.Request, dagnode ipld.Node) <-chan unixfs.LinkResult {
linkResults := make(chan unixfs.LinkResult) links := dagnode.Links()
go func() { linkResults := make(chan unixfs.LinkResult, len(links))
defer close(linkResults) defer close(linkResults)
for _, l := range dagnode.Links() { for _, l := range links {
select { linkResults <- unixfs.LinkResult{
case linkResults <- unixfs.LinkResult{ Link: l,
Link: l, Err: nil,
Err: nil,
}:
case <-req.Context.Done():
return
}
} }
}() }
return linkResults return linkResults
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论