dir : miner/worker.go
진행중인 sealing task 중지 함수 선언
interrupt := func() {
if stopCh != nil {
close(stopCh)
stopCh = nil
}
}
taskCh를 통해 새로운 task를 수신하면 이를 이용해 sealed block 생성
for {
select{
case task := <- w.taskCh:
// ...중략
// retrieve seal hash
sealHash := w.engine.SealHash(task.block.Header())
// ...중략
stopCh, prev = make(chan struct{}), sealHash
// ...중략
w.pendingTasks[sealHash] = task
// 각 합의 엔진의 Seal method 실행
// Seal 함수에서 sealing 후, resiltCh로 sealing 된 block 전송
if err := w.engine.Seal(w.chain, task.block, w.resultCh, stopCh); err != nil {
// dir > consensus/clique/clique.go
// ...중략
delete(w.pendingTasks, sealhash)
// ...
}
// ...중략
case <-w.exitCh:
interrupt()
return
}
}