aboutsummaryrefslogtreecommitdiffstats
path: root/miner
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-03-16 17:20:02 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-03-16 17:23:26 +0800
commit0228fb57cd58147ab2c3914520c7805e25a8a1c4 (patch)
tree1540b12d2aa49ed869b2bb4bde5bd5b4c44532a0 /miner
parent2855a93ede6e9437d05a82c2397d48744621db9b (diff)
downloaddexon-0228fb57cd58147ab2c3914520c7805e25a8a1c4.tar
dexon-0228fb57cd58147ab2c3914520c7805e25a8a1c4.tar.gz
dexon-0228fb57cd58147ab2c3914520c7805e25a8a1c4.tar.bz2
dexon-0228fb57cd58147ab2c3914520c7805e25a8a1c4.tar.lz
dexon-0228fb57cd58147ab2c3914520c7805e25a8a1c4.tar.xz
dexon-0228fb57cd58147ab2c3914520c7805e25a8a1c4.tar.zst
dexon-0228fb57cd58147ab2c3914520c7805e25a8a1c4.zip
eth, miner: fetch pending block/state in on go (data race)
Diffstat (limited to 'miner')
-rw-r--r--miner/miner.go9
-rw-r--r--miner/worker.go12
2 files changed, 6 insertions, 15 deletions
diff --git a/miner/miner.go b/miner/miner.go
index 6d4a84f1a..e52cefaab 100644
--- a/miner/miner.go
+++ b/miner/miner.go
@@ -164,12 +164,9 @@ func (self *Miner) SetExtra(extra []byte) error {
return nil
}
-func (self *Miner) PendingState() *state.StateDB {
- return self.worker.pendingState()
-}
-
-func (self *Miner) PendingBlock() *types.Block {
- return self.worker.pendingBlock()
+// Pending returns the currently pending block and associated state.
+func (self *Miner) Pending() (*types.Block, *state.StateDB) {
+ return self.worker.pending()
}
func (self *Miner) SetEtherbase(addr common.Address) {
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() {