diff options
author | obscuren <geffobscura@gmail.com> | 2014-04-27 22:50:44 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-04-27 22:53:35 +0800 |
commit | 16e52327a4baa5547c38965fce53b3ff40b98173 (patch) | |
tree | 27fb43512c802e2c3c0fe8bd8d97a55aa2499758 /ethchain/state.go | |
parent | 05d2d8f27d0bea5b20be9bc3b4a259a12298ecab (diff) | |
download | go-tangerine-16e52327a4baa5547c38965fce53b3ff40b98173.tar go-tangerine-16e52327a4baa5547c38965fce53b3ff40b98173.tar.gz go-tangerine-16e52327a4baa5547c38965fce53b3ff40b98173.tar.bz2 go-tangerine-16e52327a4baa5547c38965fce53b3ff40b98173.tar.lz go-tangerine-16e52327a4baa5547c38965fce53b3ff40b98173.tar.xz go-tangerine-16e52327a4baa5547c38965fce53b3ff40b98173.tar.zst go-tangerine-16e52327a4baa5547c38965fce53b3ff40b98173.zip |
Upped version number
Diffstat (limited to 'ethchain/state.go')
-rw-r--r-- | ethchain/state.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/ethchain/state.go b/ethchain/state.go index fa63accf8..1b5655d4c 100644 --- a/ethchain/state.go +++ b/ethchain/state.go @@ -47,6 +47,7 @@ func (s *State) Purge() int { return s.trie.NewIterator().Purge() } +// XXX Deprecated func (s *State) GetContract(addr []byte) *StateObject { data := s.trie.Get(string(addr)) if data == "" { @@ -68,6 +69,32 @@ func (s *State) GetContract(addr []byte) *StateObject { return contract } +func (s *State) GetStateObject(addr []byte) *StateObject { + data := s.trie.Get(string(addr)) + if data == "" { + return nil + } + + stateObject := NewStateObjectFromBytes(addr, []byte(data)) + + // Check if there's a cached state for this contract + cachedStateObject := s.states[string(addr)] + if cachedStateObject != nil { + stateObject.state = cachedStateObject + } else { + // If it isn't cached, cache the state + s.states[string(addr)] = stateObject.state + } + + return stateObject +} + +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 == "" { @@ -97,6 +124,7 @@ const ( UnknownTy ) +/* // Returns the object stored at key and the type stored at key // Returns nil if nothing is stored func (s *State) GetStateObject(key []byte) (*ethutil.Value, ObjType) { @@ -124,6 +152,7 @@ func (s *State) GetStateObject(key []byte) (*ethutil.Value, ObjType) { return val, typ } +*/ // Updates any given state object func (s *State) UpdateStateObject(object *StateObject) { |