aboutsummaryrefslogtreecommitdiffstats
path: root/core/state
diff options
context:
space:
mode:
Diffstat (limited to 'core/state')
-rw-r--r--core/state/managed_state_test.go2
-rw-r--r--core/state/state_test.go6
-rw-r--r--core/state/statedb.go10
3 files changed, 9 insertions, 9 deletions
diff --git a/core/state/managed_state_test.go b/core/state/managed_state_test.go
index 58e77d842..0b53a42c5 100644
--- a/core/state/managed_state_test.go
+++ b/core/state/managed_state_test.go
@@ -27,7 +27,7 @@ var addr = common.BytesToAddress([]byte("test"))
func create() (*ManagedState, *account) {
db, _ := ethdb.NewMemDatabase()
- statedb := New(common.Hash{}, db)
+ statedb, _ := New(common.Hash{}, db)
ms := ManageState(statedb)
so := &StateObject{address: addr, nonce: 100}
ms.StateDB.stateObjects[addr.Str()] = so
diff --git a/core/state/state_test.go b/core/state/state_test.go
index b5a7f4081..08fbc47fa 100644
--- a/core/state/state_test.go
+++ b/core/state/state_test.go
@@ -77,12 +77,12 @@ func (s *StateSuite) TestDump(c *checker.C) {
func (s *StateSuite) SetUpTest(c *checker.C) {
db, _ := ethdb.NewMemDatabase()
- s.state = New(common.Hash{}, db)
+ s.state, _ = New(common.Hash{}, db)
}
func TestNull(t *testing.T) {
db, _ := ethdb.NewMemDatabase()
- state := New(common.Hash{}, db)
+ state, _ := New(common.Hash{}, db)
address := common.HexToAddress("0x823140710bf13990e4500136726d8b55")
state.CreateAccount(address)
@@ -122,7 +122,7 @@ func (s *StateSuite) TestSnapshot(c *checker.C) {
// printing/logging in tests (-check.vv does not work)
func TestSnapshot2(t *testing.T) {
db, _ := ethdb.NewMemDatabase()
- state := New(common.Hash{}, db)
+ state, _ := New(common.Hash{}, db)
stateobjaddr0 := toAddr([]byte("so0"))
stateobjaddr1 := toAddr([]byte("so1"))
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()