diff options
author | obscuren <geffobscura@gmail.com> | 2014-06-20 06:41:42 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-06-20 06:41:42 +0800 |
commit | 6fcc6a2f7c35f10a8be3fc90bab39f2865adace9 (patch) | |
tree | 5e2304afd68aab66cf1939e7dcfededfbe126ad4 /ethchain | |
parent | 0b8ba1d55b6b4cdb63e0967790e34b1b499b638f (diff) | |
download | dexon-6fcc6a2f7c35f10a8be3fc90bab39f2865adace9.tar.gz dexon-6fcc6a2f7c35f10a8be3fc90bab39f2865adace9.tar.zst dexon-6fcc6a2f7c35f10a8be3fc90bab39f2865adace9.zip |
Changed copy/set
Diffstat (limited to 'ethchain')
-rw-r--r-- | ethchain/state_object.go | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/ethchain/state_object.go b/ethchain/state_object.go index 5fc738fee..5b64c3b37 100644 --- a/ethchain/state_object.go +++ b/ethchain/state_object.go @@ -48,7 +48,7 @@ func MakeContract(tx *Transaction, state *State) *StateObject { } func NewStateObject(addr []byte) *StateObject { - return &StateObject{address: addr, Amount: new(big.Int)} + return &StateObject{address: addr, Amount: new(big.Int), gasPool: new(big.Int)} } func NewContract(address []byte, Amount *big.Int, root []byte) *StateObject { @@ -177,6 +177,26 @@ func (self *StateObject) RefundGas(gas, price *big.Int) { } func (self *StateObject) Copy() *StateObject { + stateObject := NewStateObject(self.Address()) + stateObject.Amount.Set(self.Amount) + stateObject.ScriptHash = ethutil.CopyBytes(self.ScriptHash) + stateObject.Nonce = self.Nonce + if self.state != nil { + stateObject.state = self.state.Copy() + } + stateObject.script = ethutil.CopyBytes(self.script) + stateObject.initScript = ethutil.CopyBytes(self.initScript) + //stateObject.gasPool.Set(self.gasPool) + + return self +} + +func (self *StateObject) Set(stateObject *StateObject) { + self = stateObject +} + +/* +func (self *StateObject) Copy() *StateObject { stCopy := &StateObject{} stCopy.address = make([]byte, len(self.address)) copy(stCopy.address, self.address) @@ -194,6 +214,7 @@ func (self *StateObject) Copy() *StateObject { return stCopy } +*/ // Returns the address of the contract/account func (c *StateObject) Address() []byte { |