aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/state.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-07-07 19:59:09 +0800
committerobscuren <geffobscura@gmail.com>2014-07-07 19:59:09 +0800
commitb01cb2406f94745277fe05dfa74c6e5d42af1c6a (patch)
treee2c2ef277dfe92dc7710501234c6dec807ea6842 /ethchain/state.go
parent42bb3d8aaeb4753ac491c31c746b065dbcbb3781 (diff)
downloaddexon-b01cb2406f94745277fe05dfa74c6e5d42af1c6a.tar.gz
dexon-b01cb2406f94745277fe05dfa74c6e5d42af1c6a.tar.zst
dexon-b01cb2406f94745277fe05dfa74c6e5d42af1c6a.zip
Fixed state reset case
Diffstat (limited to 'ethchain/state.go')
-rw-r--r--ethchain/state.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/ethchain/state.go b/ethchain/state.go
index 5d023df7b..6abf21c39 100644
--- a/ethchain/state.go
+++ b/ethchain/state.go
@@ -67,11 +67,19 @@ func (self *State) Empty() {
func (self *State) Update() {
for _, stateObject := range self.stateObjects {
if stateObject.remove {
- self.trie.Delete(string(stateObject.Address()))
+ self.DeleteStateObject(stateObject)
} else {
+ println(ethutil.Bytes2Hex(stateObject.Address()))
self.UpdateStateObject(stateObject)
}
}
+
+ // FIXME trie delete is broken
+ valid, t2 := ethtrie.ParanoiaCheck(self.trie)
+ if !valid {
+ self.trie = t2
+ }
+
}
// Purges the current trie.
@@ -100,6 +108,12 @@ func (self *State) UpdateStateObject(stateObject *StateObject) {
self.manifest.AddObjectChange(stateObject)
}
+func (self *State) DeleteStateObject(stateObject *StateObject) {
+ self.trie.Delete(string(stateObject.Address()))
+
+ delete(self.stateObjects, string(stateObject.Address()))
+}
+
func (self *State) GetStateObject(addr []byte) *StateObject {
stateObject := self.stateObjects[string(addr)]
if stateObject != nil {