aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-07-20 19:37:43 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-07-20 19:37:43 +0800
commit30293497617b19a2f55633ac0680fbe2234607e0 (patch)
tree3963050484f0a53c3756df342ad0f7ae179af470
parent02c5022742e2bf6d2aadca06a6a1655214ba9d55 (diff)
downloadgo-tangerine-30293497617b19a2f55633ac0680fbe2234607e0.tar
go-tangerine-30293497617b19a2f55633ac0680fbe2234607e0.tar.gz
go-tangerine-30293497617b19a2f55633ac0680fbe2234607e0.tar.bz2
go-tangerine-30293497617b19a2f55633ac0680fbe2234607e0.tar.lz
go-tangerine-30293497617b19a2f55633ac0680fbe2234607e0.tar.xz
go-tangerine-30293497617b19a2f55633ac0680fbe2234607e0.tar.zst
go-tangerine-30293497617b19a2f55633ac0680fbe2234607e0.zip
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: