diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-09 01:09:36 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-09 01:09:36 +0800 |
commit | 5a0bae1dae831818740a2f20ca308c4176f5201d (patch) | |
tree | 33fc52996530ebb7c467880975554a91d94471c6 /ethchain/state.go | |
parent | e8fb965ccbb65807c1f462e8f2ee82508a822b58 (diff) | |
download | go-tangerine-5a0bae1dae831818740a2f20ca308c4176f5201d.tar.gz go-tangerine-5a0bae1dae831818740a2f20ca308c4176f5201d.tar.zst go-tangerine-5a0bae1dae831818740a2f20ca308c4176f5201d.zip |
Auto update state changes notifications
Diffstat (limited to 'ethchain/state.go')
-rw-r--r-- | ethchain/state.go | 35 |
1 files changed, 4 insertions, 31 deletions
diff --git a/ethchain/state.go b/ethchain/state.go index 1b5655d4c..5d42c40c0 100644 --- a/ethchain/state.go +++ b/ethchain/state.go @@ -15,11 +15,13 @@ type State struct { trie *ethutil.Trie // Nested states states map[string]*State + + manifest *Manifest } // Create a new state from a given trie func NewState(trie *ethutil.Trie) *State { - return &State{trie: trie, states: make(map[string]*State)} + return &State{trie: trie, states: make(map[string]*State), manifest: NewManifest()} } // Resets the trie and all siblings @@ -124,36 +126,6 @@ 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) { - // Fetch data from the trie - data := s.trie.Get(string(key)) - // Returns the nil type, indicating nothing could be retrieved. - // Anything using this function should check for this ret val - if data == "" { - return nil, NilTy - } - - var typ ObjType - val := ethutil.NewValueFromBytes([]byte(data)) - // Check the length of the retrieved value. - // Len 2 = Account - // Len 3 = Contract - // Other = invalid for now. If other types emerge, add them here - if val.Len() == 2 { - typ = AccountTy - } else if val.Len() == 3 { - typ = ContractTy - } else { - typ = UnknownTy - } - - return val, typ -} -*/ - // Updates any given state object func (s *State) UpdateStateObject(object *StateObject) { addr := object.Address() @@ -163,6 +135,7 @@ func (s *State) UpdateStateObject(object *StateObject) { } s.trie.Update(string(addr), string(object.RlpEncode())) + s.manifest.AddObjectChange(object) } func (s *State) Put(key, object []byte) { |