From 1b1f293082044c43d8d1c5df9ac40aab8fdb2ae8 Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Tue, 6 Oct 2015 16:35:55 +0200 Subject: core/state, core, miner: handle missing root error from state.New --- core/state/statedb.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'core/state/statedb.go') diff --git a/core/state/statedb.go b/core/state/statedb.go index ad673aecb..a9de71409 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -52,12 +52,11 @@ type StateDB struct { } // Create a new state from a given trie -func New(root common.Hash, db ethdb.Database) *StateDB { +func New(root common.Hash, db ethdb.Database) (*StateDB, error) { tr, err := trie.NewSecure(root, db) if err != nil { - // TODO: bubble this up - tr, _ = trie.NewSecure(common.Hash{}, db) glog.Errorf("can't create state trie with root %x: %v", root[:], err) + return nil, err } return &StateDB{ db: db, @@ -65,7 +64,7 @@ func New(root common.Hash, db ethdb.Database) *StateDB { stateObjects: make(map[string]*StateObject), refund: new(big.Int), logs: make(map[common.Hash]vm.Logs), - } + }, nil } func (self *StateDB) StartRecord(thash, bhash common.Hash, ti int) { @@ -297,7 +296,8 @@ func (self *StateDB) CreateAccount(addr common.Address) vm.Account { // func (self *StateDB) Copy() *StateDB { - state := New(common.Hash{}, self.db) + // ignore error - we assume state-to-be-copied always exists + state, _ := New(common.Hash{}, self.db) state.trie = self.trie for k, stateObject := range self.stateObjects { state.stateObjects[k] = stateObject.Copy() -- cgit