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 /xeth | |
parent | f466243417f60531998e8b500f2bb043af5b3d2a (diff) | |
download | dexon-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar.gz dexon-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.tar.zst dexon-1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8.zip |
core/state, core, miner: handle missing root error from state.New
Diffstat (limited to 'xeth')
-rw-r--r-- | xeth/xeth.go | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/xeth/xeth.go b/xeth/xeth.go index 13e171270..3b487fed8 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -126,7 +126,11 @@ func New(ethereum *eth.Ethereum, frontend Frontend) *XEth { if frontend == nil { xeth.frontend = dummyFrontend{} } - xeth.state = NewState(xeth, xeth.backend.BlockChain().State()) + state, err := xeth.backend.BlockChain().State() + if err != nil { + return nil + } + xeth.state = NewState(xeth, state) go xeth.start() @@ -207,14 +211,21 @@ func (self *XEth) RemoteMining() *miner.RemoteAgent { return self.agent } func (self *XEth) AtStateNum(num int64) *XEth { var st *state.StateDB + var err error switch num { case -2: st = self.backend.Miner().PendingState().Copy() default: if block := self.getBlockByHeight(num); block != nil { - st = state.New(block.Root(), self.backend.ChainDb()) + st, err = state.New(block.Root(), self.backend.ChainDb()) + if err != nil { + return nil + } } else { - st = state.New(self.backend.BlockChain().GetBlockByNumber(0).Root(), self.backend.ChainDb()) + st, err = state.New(self.backend.BlockChain().GetBlockByNumber(0).Root(), self.backend.ChainDb()) + if err != nil { + return nil + } } } @@ -266,7 +277,11 @@ func (self *XEth) UpdateState() (wait chan *big.Int) { wait <- n n = nil } - statedb := state.New(event.Block.Root(), self.backend.ChainDb()) + statedb, err := state.New(event.Block.Root(), self.backend.ChainDb()) + if err != nil { + glog.V(logger.Error).Infoln("Could not create new state: %v", err) + return + } self.state = NewState(self, statedb) } case n, ok = <-wait: |