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 { ...@@ -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) { 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) errs := make(chan error, 1)
blocks := ds.Blocks.GetBlocks(ctx, keys) blocks := ds.Blocks.GetBlocks(ctx, keys)
var count int var count int
go func() { go func() {
defer close(out) defer close(out)
defer close(errs)
for { for {
select { select {
case b, ok := <-blocks: case b, ok := <-blocks:
...@@ -168,13 +167,13 @@ func (ds *dagService) GetMany(ctx context.Context, keys []key.Key) (<-chan *Node ...@@ -168,13 +167,13 @@ func (ds *dagService) GetMany(ctx context.Context, keys []key.Key) (<-chan *Node
errs <- err errs <- err
return return
} }
select {
case out <- nd: // buffered, no need to select
count++ out <- nd
case <-ctx.Done(): count++
return
}
case <-ctx.Done(): case <-ctx.Done():
errs <- ctx.Err()
return 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