aboutsummaryrefslogtreecommitdiffstats
path: root/miner
diff options
context:
space:
mode:
Diffstat (limited to 'miner')
-rw-r--r--miner/agent.go2
-rw-r--r--miner/worker.go15
2 files changed, 13 insertions, 4 deletions
diff --git a/miner/agent.go b/miner/agent.go
index e80b222c8..4a4683bc6 100644
--- a/miner/agent.go
+++ b/miner/agent.go
@@ -118,7 +118,7 @@ func (self *CpuAgent) mine(work *Work, stop <-chan struct{}) {
glog.V(logger.Debug).Infof("(re)started agent[%d]. mining...\n", self.index)
// Mine
- nonce, mixDigest := self.pow.Search(work.Block, stop)
+ nonce, mixDigest := self.pow.Search(work.Block, stop, self.index)
if nonce != 0 {
block := work.Block.WithMiningResult(nonce, common.BytesToHash(mixDigest))
self.returnCh <- &Result{work, block}
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