eth, miner: fetch pending block/state in on go (data race)

This commit is contained in:
Péter Szilágyi
2016-03-16 11:20:02 +02:00
parent 2855a93ede
commit 0228fb57cd
3 changed files with 10 additions and 17 deletions

View File

@ -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() {