MCPcopy Create free account
hub / github.com/ethstorage/es-node / taskLoop

Method taskLoop

ethstorage/miner/worker.go:368–390  ·  view source on GitHub ↗

taskLoop is a standalone goroutine to fetch mining task from the task channel and mine the task.

(taskCh chan *taskItem)

Source from the content-addressed store, hash-verified

366
367// taskLoop is a standalone goroutine to fetch mining task from the task channel and mine the task.
368func (w *worker) taskLoop(taskCh chan *taskItem) {
369 defer w.wg.Done()
370 for {
371 select {
372 case ti := <-taskCh:
373 success, err := w.mineTask(ti)
374 if err != nil {
375 select {
376 case errCh <- miningError{ti.shardIdx, ti.blockNumber, err}:
377 default:
378 w.lg.Warn("Sent miningError to errCh failed", "lenOfCh", len(errCh))
379 }
380 w.lg.Warn("Mine task fail", "shard", ti.shardIdx, "thread", ti.thread, "block", ti.blockNumber, "err", err.Error())
381 }
382 if success {
383 w.lg.Info("Mine task success", "shard", ti.shardIdx, "thread", ti.thread, "block", ti.blockNumber)
384 }
385 case <-w.exitCh:
386 w.lg.Debug("Worker is exiting from task loop...")
387 return
388 }
389 }
390}
391
392func (w *worker) getResult() *result {
393 w.resultLock.Lock()

Callers 1

newWorkLoopMethod · 0.95

Calls 2

mineTaskMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected