miner: fix data race in tests (#20310)

* miner: fix data race in tests

miner: fix linter

* miner: address comment
This commit is contained in:
gary rong
2019-11-20 18:36:41 +08:00
committed by Péter Szilágyi
parent f71e85b8e2
commit 9b59c75405
3 changed files with 28 additions and 104 deletions

View File

@ -176,7 +176,7 @@ type worker struct {
resubmitHook func(time.Duration, time.Duration) // Method to call upon updating resubmitting interval.
}
func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus.Engine, eth Backend, mux *event.TypeMux, isLocalBlock func(*types.Block) bool) *worker {
func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus.Engine, eth Backend, mux *event.TypeMux, isLocalBlock func(*types.Block) bool, init bool) *worker {
worker := &worker{
config: config,
chainConfig: chainConfig,
@ -219,8 +219,9 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus
go worker.taskLoop()
// Submit first work to initialize pending state.
worker.startCh <- struct{}{}
if init {
worker.startCh <- struct{}{}
}
return worker
}