aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-07-20 19:37:43 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-07-23 16:41:49 +0800
commitc9d6fba07ddae0302d5bf10ac23558eb84b2f18e (patch)
tree53696bfd982ba832474d88d7151374a6b9b06a5c
parent228fc5a83a67d76ddd58cc77dcf8a73dce9a9e06 (diff)
downloadgo-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.go5
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: