aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-07-22 18:16:13 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-07-22 18:16:13 +0800
commit482cc4957d274ec101bb74a76ed34579ef1e4f28 (patch)
tree93e938b20a2ea7d0d799614d9bcf2b37f704ecf6
parentf1daed65b1f89cae6327cd9f49668628c6980ade (diff)
parent30293497617b19a2f55633ac0680fbe2234607e0 (diff)
downloaddexon-482cc4957d274ec101bb74a76ed34579ef1e4f28.tar
dexon-482cc4957d274ec101bb74a76ed34579ef1e4f28.tar.gz
dexon-482cc4957d274ec101bb74a76ed34579ef1e4f28.tar.bz2
dexon-482cc4957d274ec101bb74a76ed34579ef1e4f28.tar.lz
dexon-482cc4957d274ec101bb74a76ed34579ef1e4f28.tar.xz
dexon-482cc4957d274ec101bb74a76ed34579ef1e4f28.tar.zst
dexon-482cc4957d274ec101bb74a76ed34579ef1e4f28.zip
Merge pull request #1500 from karalabe/fix-miner-race
miner: fix current work data race
-rw-r--r--miner/worker.go5
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: