good morning!!!!

Skip to content
Snippets Groups Projects
Commit 30293497 authored by Péter Szilágyi's avatar Péter Szilágyi
Browse files

miner: fix current work data race

parent 02c50227
No related branches found
No related tags found
No related merge requests found
...@@ -160,6 +160,7 @@ func (self *worker) pendingState() *state.StateDB { ...@@ -160,6 +160,7 @@ func (self *worker) pendingState() *state.StateDB {
func (self *worker) pendingBlock() *types.Block { func (self *worker) pendingBlock() *types.Block {
self.currentMu.Lock() self.currentMu.Lock()
defer self.currentMu.Unlock() defer self.currentMu.Unlock()
if atomic.LoadInt32(&self.mining) == 0 { if atomic.LoadInt32(&self.mining) == 0 {
return types.NewBlock( return types.NewBlock(
self.current.header, self.current.header,
...@@ -228,9 +229,9 @@ out: ...@@ -228,9 +229,9 @@ out:
case core.TxPreEvent: case core.TxPreEvent:
// Apply transaction to the pending state if we're not mining // Apply transaction to the pending state if we're not mining
if atomic.LoadInt32(&self.mining) == 0 { if atomic.LoadInt32(&self.mining) == 0 {
self.mu.Lock() self.currentMu.Lock()
self.current.commitTransactions(types.Transactions{ev.Tx}, self.gasPrice, self.proc) self.current.commitTransactions(types.Transactions{ev.Tx}, self.gasPrice, self.proc)
self.mu.Unlock() self.currentMu.Unlock()
} }
} }
case <-self.quit: case <-self.quit:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment