Commit b88c9c04 authored by Jeromy's avatar Jeromy

fixes from review

License: MIT
Signed-off-by: default avatarJeromy <jeromyj@gmail.com>
parent f8108394
......@@ -146,14 +146,13 @@ func FindLinks(links []key.Key, k key.Key, start int) []int {
}
func (ds *dagService) GetMany(ctx context.Context, keys []key.Key) (<-chan *Node, <-chan error) {
out := make(chan *Node)
out := make(chan *Node, len(keys))
errs := make(chan error, 1)
blocks := ds.Blocks.GetBlocks(ctx, keys)
var count int
go func() {
defer close(out)
defer close(errs)
for {
select {
case b, ok := <-blocks:
......@@ -168,13 +167,13 @@ func (ds *dagService) GetMany(ctx context.Context, keys []key.Key) (<-chan *Node
errs <- err
return
}
select {
case out <- nd:
// buffered, no need to select
out <- nd
count++
case <-ctx.Done():
return
}
case <-ctx.Done():
errs <- ctx.Err()
return
}
}
......
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