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 /core/state/statedb.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 'core/state/statedb.go')
-rw-r--r-- | core/state/statedb.go | 10 |
1 files changed, 5 insertions, 5 deletions
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() |