diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-20 17:19:07 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-20 17:19:07 +0800 |
commit | fd19142c0db3d2b6651989f5389944f3e211d84f (patch) | |
tree | 96916597bc7366fad5043acb6df7a2711675f504 /ethchain/state_object.go | |
parent | a2fb265563a3a6eb80efc5720bb0c6f3fec6f397 (diff) | |
download | go-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_object.go')
-rw-r--r-- | ethchain/state_object.go | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/ethchain/state_object.go b/ethchain/state_object.go index 7a11a1152..cb6211ea6 100644 --- a/ethchain/state_object.go +++ b/ethchain/state_object.go @@ -10,8 +10,9 @@ type StateObject struct { // Address of the object address []byte // Shared attributes - Amount *big.Int - Nonce uint64 + Amount *big.Int + ScriptHash []byte + Nonce uint64 // Contract related attributes state *State script []byte @@ -22,12 +23,10 @@ type StateObject struct { func MakeContract(tx *Transaction, state *State) *StateObject { // Create contract if there's no recipient if tx.IsContract() { - // FIXME - addr := tx.Hash()[12:] + addr := tx.CreationAddress() value := tx.Value - contract := NewContract(addr, value, []byte("")) - state.UpdateStateObject(contract) + contract := NewContract(addr, value, ZeroHash256) contract.script = tx.Data contract.initScript = tx.Init @@ -146,9 +145,10 @@ func (c *StateObject) RlpEncode() []byte { if c.state != nil { root = c.state.trie.Root } else { - root = nil + root = ZeroHash256 } - return ethutil.Encode([]interface{}{c.Amount, c.Nonce, root, c.script}) + + return ethutil.Encode([]interface{}{c.Amount, c.Nonce, root, ethutil.Sha3Bin(c.script)}) } func (c *StateObject) RlpDecode(data []byte) { @@ -157,7 +157,10 @@ func (c *StateObject) RlpDecode(data []byte) { c.Amount = decoder.Get(0).BigInt() c.Nonce = decoder.Get(1).Uint() c.state = NewState(ethutil.NewTrie(ethutil.Config.Db, decoder.Get(2).Interface())) - c.script = decoder.Get(3).Bytes() + + c.ScriptHash = decoder.Get(3).Bytes() + + c.script, _ = ethutil.Config.Db.Get(c.ScriptHash) } // Storage change object. Used by the manifest for notifying changes to |