mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-12 19:16:41 +00:00
miner: fix current work data race
This commit is contained in:
parent
228fc5a83a
commit
c9d6fba07d
1 changed files with 3 additions and 2 deletions
|
|
@ -155,6 +155,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,
|
||||||
|
|
@ -223,9 +224,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:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue