Commit e55ff35f authored by Brian Tiger Chow's avatar Brian Tiger Chow Committed by Jeromy

fix(merkle) use defer

parent c5d14421
...@@ -307,6 +307,8 @@ func FindLink(n *Node, k u.Key, found []*Node) (int, error) { ...@@ -307,6 +307,8 @@ func FindLink(n *Node, k u.Key, found []*Node) (int, error) {
func (ds *dagService) GetDAG(ctx context.Context, root *Node) <-chan *Node { func (ds *dagService) GetDAG(ctx context.Context, root *Node) <-chan *Node {
sig := make(chan *Node) sig := make(chan *Node)
go func() { go func() {
defer close(sig)
var keys []u.Key var keys []u.Key
for _, lnk := range root.Links { for _, lnk := range root.Links {
keys = append(keys, u.Key(lnk.Hash)) keys = append(keys, u.Key(lnk.Hash))
...@@ -350,7 +352,6 @@ func (ds *dagService) GetDAG(ctx context.Context, root *Node) <-chan *Node { ...@@ -350,7 +352,6 @@ func (ds *dagService) GetDAG(ctx context.Context, root *Node) <-chan *Node {
// TODO: bubble errors back up. // TODO: bubble errors back up.
log.Errorf("Did not receive correct number of nodes!") log.Errorf("Did not receive correct number of nodes!")
} }
close(sig)
}() }()
return sig return sig
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment