Merge pull request #1500 from karalabe/fix-miner-race

miner: fix current work data race
This commit is contained in:
Jeffrey Wilcke 2015-07-22 03:16:13 -07:00
commit 482cc4957d
1 changed files with 3 additions and 2 deletions

View File

@ -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: