提交 ed019e2f 作者: Brian Tiger Chow

one worker

上级 721ff572
...@@ -114,32 +114,30 @@ func (w *Worker) start(c Config) { ...@@ -114,32 +114,30 @@ func (w *Worker) start(c Config) {
} }
}) })
for i := 0; i < c.NumWorkers; i++ { // reads from |workerChan| until process closes
// reads from |workerChan| until process closes w.process.Go(func(proc process.Process) {
w.process.Go(func(proc process.Process) { ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(context.Background())
// shuts down an in-progress HasBlock operation
// shuts down an in-progress HasBlock operation proc.Go(func(proc process.Process) {
proc.Go(func(proc process.Process) { <-proc.Closing()
<-proc.Closing() cancel()
cancel() })
})
for {
for { select {
select { case <-proc.Closing():
case <-proc.Closing(): return
case block, ok := <-workerChan:
if !ok {
return return
case block, ok := <-workerChan: }
if !ok { if err := w.exchange.HasBlock(ctx, block); err != nil {
return // TODO log event?
}
if err := w.exchange.HasBlock(ctx, block); err != nil {
// TODO log event?
}
} }
} }
}) }
} })
} }
type BlockList struct { type BlockList struct {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论