diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-07-20 19:37:43 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-07-23 16:41:49 +0800 |
commit | c9d6fba07ddae0302d5bf10ac23558eb84b2f18e (patch) | |
tree | 53696bfd982ba832474d88d7151374a6b9b06a5c | |
parent | 228fc5a83a67d76ddd58cc77dcf8a73dce9a9e06 (diff) | |
download | go-tangerine-c9d6fba07ddae0302d5bf10ac23558eb84b2f18e.tar go-tangerine-c9d6fba07ddae0302d5bf10ac23558eb84b2f18e.tar.gz go-tangerine-c9d6fba07ddae0302d5bf10ac23558eb84b2f18e.tar.bz2 go-tangerine-c9d6fba07ddae0302d5bf10ac23558eb84b2f18e.tar.lz go-tangerine-c9d6fba07ddae0302d5bf10ac23558eb84b2f18e.tar.xz go-tangerine-c9d6fba07ddae0302d5bf10ac23558eb84b2f18e.tar.zst go-tangerine-c9d6fba07ddae0302d5bf10ac23558eb84b2f18e.zip |
miner: fix current work data race
-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 9f804bf30..900101987 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -155,6 +155,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, @@ -223,9 +224,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: |