diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-07-22 18:16:13 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-07-22 18:16:13 +0800 |
commit | 482cc4957d274ec101bb74a76ed34579ef1e4f28 (patch) | |
tree | 93e938b20a2ea7d0d799614d9bcf2b37f704ecf6 | |
parent | f1daed65b1f89cae6327cd9f49668628c6980ade (diff) | |
parent | 30293497617b19a2f55633ac0680fbe2234607e0 (diff) | |
download | go-tangerine-482cc4957d274ec101bb74a76ed34579ef1e4f28.tar go-tangerine-482cc4957d274ec101bb74a76ed34579ef1e4f28.tar.gz go-tangerine-482cc4957d274ec101bb74a76ed34579ef1e4f28.tar.bz2 go-tangerine-482cc4957d274ec101bb74a76ed34579ef1e4f28.tar.lz go-tangerine-482cc4957d274ec101bb74a76ed34579ef1e4f28.tar.xz go-tangerine-482cc4957d274ec101bb74a76ed34579ef1e4f28.tar.zst go-tangerine-482cc4957d274ec101bb74a76ed34579ef1e4f28.zip |
Merge pull request #1500 from karalabe/fix-miner-race
miner: fix current work data race
-rw-r--r-- | miner/worker.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/miner/worker.go b/miner/worker.go index 90ef79e3f..a4ebe6fe7 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -160,6 +160,7 @@ func (self *worker) pendingState() *state.StateDB { func (self *worker) pendingBlock() *types.Block { self.currentMu.Lock() defer self.currentMu.Unlock() + if atomic.LoadInt32(&self.mining) == 0 { return types.NewBlock( self.current.header, @@ -228,9 +229,9 @@ out: case core.TxPreEvent: // Apply transaction to the pending state if we're not mining if atomic.LoadInt32(&self.mining) == 0 { - self.mu.Lock() + self.currentMu.Lock() self.current.commitTransactions(types.Transactions{ev.Tx}, self.gasPrice, self.proc) - self.mu.Unlock() + self.currentMu.Unlock() } } case <-self.quit: |