aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/state.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-05-20 17:19:07 +0800
committerobscuren <geffobscura@gmail.com>2014-05-20 17:19:07 +0800
commitfd19142c0db3d2b6651989f5389944f3e211d84f (patch)
tree96916597bc7366fad5043acb6df7a2711675f504 /ethchain/state.go
parenta2fb265563a3a6eb80efc5720bb0c6f3fec6f397 (diff)
downloadgo-tangerine-fd19142c0db3d2b6651989f5389944f3e211d84f.tar
go-tangerine-fd19142c0db3d2b6651989f5389944f3e211d84f.tar.gz
go-tangerine-fd19142c0db3d2b6651989f5389944f3e211d84f.tar.bz2
go-tangerine-fd19142c0db3d2b6651989f5389944f3e211d84f.tar.lz
go-tangerine-fd19142c0db3d2b6651989f5389944f3e211d84f.tar.xz
go-tangerine-fd19142c0db3d2b6651989f5389944f3e211d84f.tar.zst
go-tangerine-fd19142c0db3d2b6651989f5389944f3e211d84f.zip
No longer store script directly in the state tree
Diffstat (limited to 'ethchain/state.go')
-rw-r--r--ethchain/state.go49
1 files changed, 15 insertions, 34 deletions
diff --git a/ethchain/state.go b/ethchain/state.go
index d02584d67..63c4a32a6 100644
--- a/ethchain/state.go
+++ b/ethchain/state.go
@@ -49,28 +49,6 @@ 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 == "" {
- return nil
- }
-
- // build contract
- contract := NewStateObjectFromBytes(addr, []byte(data))
-
- // Check if there's a cached state for this contract
- cachedState := s.states[string(addr)]
- if cachedState != nil {
- contract.state = cachedState
- } else {
- // If it isn't cached, cache the state
- s.states[string(addr)] = contract.state
- }
-
- return contract
-}
-
func (s *State) GetStateObject(addr []byte) *StateObject {
data := s.trie.Get(string(addr))
if data == "" {
@@ -91,6 +69,21 @@ func (s *State) GetStateObject(addr []byte) *StateObject {
return stateObject
}
+// Updates any given state object
+func (s *State) UpdateStateObject(object *StateObject) {
+ addr := object.Address()
+
+ if object.state != nil {
+ s.states[string(addr)] = object.state
+ }
+
+ ethutil.Config.Db.Put(ethutil.Sha3Bin(object.Script()), object.Script())
+
+ s.trie.Update(string(addr), string(object.RlpEncode()))
+
+ s.manifest.AddObjectChange(object)
+}
+
func (s *State) SetStateObject(stateObject *StateObject) {
s.states[string(stateObject.address)] = stateObject.state
@@ -116,18 +109,6 @@ func (s *State) Copy() *State {
return NewState(s.trie.Copy())
}
-// Updates any given state object
-func (s *State) UpdateStateObject(object *StateObject) {
- addr := object.Address()
-
- if object.state != nil {
- s.states[string(addr)] = object.state
- }
-
- s.trie.Update(string(addr), string(object.RlpEncode()))
- s.manifest.AddObjectChange(object)
-}
-
func (s *State) Put(key, object []byte) {
s.trie.Update(string(key), string(object))
}