aboutsummaryrefslogtreecommitdiffstats
path: root/miner/worker.go
diff options
context:
space:
mode:
Diffstat (limited to 'miner/worker.go')
-rw-r--r--miner/worker.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/miner/worker.go b/miner/worker.go
index 57f668d49..5bce32f21 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -355,8 +355,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(),
@@ -387,6 +390,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) {
@@ -466,7 +470,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