diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-21 07:12:28 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-21 07:12:28 +0800 |
commit | 3c35ba7c31423da644c5fb73030af4673cff90ec (patch) | |
tree | c8e19b5a16b70780d6d837c3a60a260b13c6fd62 /ethchain/state.go | |
parent | 6ef2832083ad9d1e3cb1895f1aa836517dbf042d (diff) | |
download | dexon-3c35ba7c31423da644c5fb73030af4673cff90ec.tar dexon-3c35ba7c31423da644c5fb73030af4673cff90ec.tar.gz dexon-3c35ba7c31423da644c5fb73030af4673cff90ec.tar.bz2 dexon-3c35ba7c31423da644c5fb73030af4673cff90ec.tar.lz dexon-3c35ba7c31423da644c5fb73030af4673cff90ec.tar.xz dexon-3c35ba7c31423da644c5fb73030af4673cff90ec.tar.zst dexon-3c35ba7c31423da644c5fb73030af4673cff90ec.zip |
Fixed state overwriting issue
Diffstat (limited to 'ethchain/state.go')
-rw-r--r-- | ethchain/state.go | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/ethchain/state.go b/ethchain/state.go index db715f1cb..6ec6916f4 100644 --- a/ethchain/state.go +++ b/ethchain/state.go @@ -60,6 +60,7 @@ func (s *State) GetStateObject(addr []byte) *StateObject { // Check if there's a cached state for this contract cachedStateObject := s.states[string(addr)] if cachedStateObject != nil { + //fmt.Printf("get cached #%d %x addr: %x\n", cachedStateObject.trie.Cache().Len(), cachedStateObject.Root(), addr[0:4]) stateObject.state = cachedStateObject } @@ -70,8 +71,9 @@ func (s *State) GetStateObject(addr []byte) *StateObject { func (s *State) UpdateStateObject(object *StateObject) { addr := object.Address() - if object.state != nil { + if object.state != nil && s.states[string(addr)] == nil { s.states[string(addr)] = object.state + //fmt.Printf("update cached #%d %x addr: %x\n", object.state.trie.Cache().Len(), object.state.Root(), addr[0:4]) } ethutil.Config.Db.Put(ethutil.Sha3Bin(object.Script()), object.Script()) @@ -81,12 +83,6 @@ func (s *State) UpdateStateObject(object *StateObject) { s.manifest.AddObjectChange(object) } -func (s *State) SetStateObject(stateObject *StateObject) { - s.states[string(stateObject.address)] = stateObject.state - - s.UpdateStateObject(stateObject) -} - func (s *State) GetAccount(addr []byte) (account *StateObject) { data := s.trie.Get(string(addr)) if data == "" { |