diff options
author | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-10-06 22:35:55 +0800 |
---|---|---|
committer | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-10-16 08:22:06 +0800 |
commit | 1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8 (patch) | |
tree | fefd9cfe28ce5b409d58c70b03cf4a6d6dc84873 /miner/worker.go | |
parent | f466243417f60531998e8b500f2bb043af5b3d2a (diff) | |
download | dexon-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar dexon-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar.gz dexon-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar.bz2 dexon-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar.lz dexon-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar.xz dexon-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar.zst dexon-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.zip |
core/state, core, miner: handle missing root error from state.New
Diffstat (limited to 'miner/worker.go')
-rw-r--r-- | miner/worker.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/miner/worker.go b/miner/worker.go index 43f6f9909..83653e327 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -353,8 +353,11 @@ func (self *worker) push(work *Work) { } // makeCurrent creates a new environment for the current cycle. -func (self *worker) makeCurrent(parent *types.Block, header *types.Header) { - state := state.New(parent.Root(), self.eth.ChainDb()) +func (self *worker) makeCurrent(parent *types.Block, header *types.Header) error { + state, err := state.New(parent.Root(), self.eth.ChainDb()) + if err != nil { + return err + } work := &Work{ state: state, ancestors: set.New(), @@ -385,6 +388,7 @@ func (self *worker) makeCurrent(parent *types.Block, header *types.Header) { work.localMinedBlocks = self.current.localMinedBlocks } self.current = work + return nil } func (w *worker) setGasPrice(p *big.Int) { @@ -464,7 +468,12 @@ func (self *worker) commitNewWork() { } previous := self.current - self.makeCurrent(parent, header) + // Could potentially happen if starting to mine in an odd state. + err := self.makeCurrent(parent, header) + if err != nil { + glog.V(logger.Info).Infoln("Could not create new env for mining, retrying on next block.") + return + } work := self.current /* //approach 1 |