diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-07-20 19:37:43 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-07-20 19:37:43 +0800 |
commit | 30293497617b19a2f55633ac0680fbe2234607e0 (patch) | |
tree | 3963050484f0a53c3756df342ad0f7ae179af470 /miner/worker.go | |
parent | 02c5022742e2bf6d2aadca06a6a1655214ba9d55 (diff) | |
download | dexon-30293497617b19a2f55633ac0680fbe2234607e0.tar.gz dexon-30293497617b19a2f55633ac0680fbe2234607e0.tar.zst dexon-30293497617b19a2f55633ac0680fbe2234607e0.zip |
miner: fix current work data race
Diffstat (limited to 'miner/worker.go')
-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: |