Skip to content

Commit 482cc49

Browse files
committed
Merge pull request #1500 from karalabe/fix-miner-race
miner: fix current work data race
2 parents f1daed6 + 3029349 commit 482cc49

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

miner/worker.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ func (self *worker) pendingState() *state.StateDB {
160160
func (self *worker) pendingBlock() *types.Block {
161161
self.currentMu.Lock()
162162
defer self.currentMu.Unlock()
163+
163164
if atomic.LoadInt32(&self.mining) == 0 {
164165
return types.NewBlock(
165166
self.current.header,
@@ -228,9 +229,9 @@ out:
228229
case core.TxPreEvent:
229230
// Apply transaction to the pending state if we're not mining
230231
if atomic.LoadInt32(&self.mining) == 0 {
231-
self.mu.Lock()
232+
self.currentMu.Lock()
232233
self.current.commitTransactions(types.Transactions{ev.Tx}, self.gasPrice, self.proc)
233-
self.mu.Unlock()
234+
self.currentMu.Unlock()
234235
}
235236
}
236237
case <-self.quit:

0 commit comments

Comments
 (0)