Commit 0c12b7a0 authored by Jeromy's avatar Jeromy

move blocking calls out of single threaded loops, cancel contexts ASAP

parent 74d015bd
......@@ -187,9 +187,12 @@ func (ds *dagService) GetNodes(ctx context.Context, keys []u.Key) []NodeGetter {
}
go func() {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
blkchan := ds.Blocks.GetBlocks(ctx, keys)
for {
for count := 0; count < len(keys); {
select {
case blk, ok := <-blkchan:
if !ok {
......@@ -205,6 +208,7 @@ func (ds *dagService) GetNodes(ctx context.Context, keys []u.Key) []NodeGetter {
is := FindLinks(keys, blk.Key(), 0)
for _, i := range is {
sendChans[i] <- nd
count++
}
case <-ctx.Done():
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