From 0228fb57cd58147ab2c3914520c7805e25a8a1c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= <peterke@gmail.com>
Date: Wed, 16 Mar 2016 11:20:02 +0200
Subject: eth, miner: fetch pending block/state in on go (data race)

---
 miner/worker.go | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

(limited to 'miner/worker.go')

diff --git a/miner/worker.go b/miner/worker.go
index f3e95cb5f..108b2d6b5 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -152,13 +152,7 @@ func (self *worker) setEtherbase(addr common.Address) {
 	self.coinbase = addr
 }
 
-func (self *worker) pendingState() *state.StateDB {
-	self.currentMu.Lock()
-	defer self.currentMu.Unlock()
-	return self.current.state
-}
-
-func (self *worker) pendingBlock() *types.Block {
+func (self *worker) pending() (*types.Block, *state.StateDB) {
 	self.currentMu.Lock()
 	defer self.currentMu.Unlock()
 
@@ -168,9 +162,9 @@ func (self *worker) pendingBlock() *types.Block {
 			self.current.txs,
 			nil,
 			self.current.receipts,
-		)
+		), self.current.state
 	}
-	return self.current.Block
+	return self.current.Block, self.current.state
 }
 
 func (self *worker) start() {
-- 
cgit v1.2.3