From 36f7fe61c3697a3e99b95fe3f3c12fc16ed2d39f Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Thu, 20 Aug 2015 18:22:50 +0200 Subject: core, tests: Double SUICIDE fix --- core/state/state_object.go | 5 +++-- core/state/statedb.go | 16 +++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'core/state') diff --git a/core/state/state_object.go b/core/state/state_object.go index 3d4f0b376..c76feb774 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -82,8 +82,9 @@ type StateObject struct { // Mark for deletion // When an object is marked for deletion it will be delete from the trie // during the "update" phase of the state transition - remove bool - dirty bool + remove bool + deleted bool + dirty bool } func (self *StateObject) Reset() { diff --git a/core/state/statedb.go b/core/state/statedb.go index 45bdfc084..577f7162e 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -203,18 +203,20 @@ func (self *StateDB) UpdateStateObject(stateObject *StateObject) { // Delete the given state object and delete it from the state trie func (self *StateDB) DeleteStateObject(stateObject *StateObject) { + stateObject.deleted = true + addr := stateObject.Address() self.trie.Delete(addr[:]) - - //delete(self.stateObjects, addr.Str()) } // Retrieve a state object given my the address. Nil if not found -func (self *StateDB) GetStateObject(addr common.Address) *StateObject { - //addr = common.Address(addr) - - stateObject := self.stateObjects[addr.Str()] +func (self *StateDB) GetStateObject(addr common.Address) (stateObject *StateObject) { + stateObject = self.stateObjects[addr.Str()] if stateObject != nil { + if stateObject.deleted { + stateObject = nil + } + return stateObject } @@ -236,7 +238,7 @@ func (self *StateDB) SetStateObject(object *StateObject) { // Retrieve a state object or create a new state object if nil func (self *StateDB) GetOrNewStateObject(addr common.Address) *StateObject { stateObject := self.GetStateObject(addr) - if stateObject == nil { + if stateObject == nil || stateObject.deleted { stateObject = self.CreateAccount(addr) } -- cgit