diff options
author | obscuren <geffobscura@gmail.com> | 2014-12-04 00:06:54 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-12-04 00:06:54 +0800 |
commit | 99853ac3ce57807deb4822dd324186e1d2ee0821 (patch) | |
tree | 4c7dc0c8fa1f83d1081f429fa3175b03c9011101 /vm/closure.go | |
parent | 82405501872385b240012070bad2f0eda643d423 (diff) | |
download | go-tangerine-99853ac3ce57807deb4822dd324186e1d2ee0821.tar go-tangerine-99853ac3ce57807deb4822dd324186e1d2ee0821.tar.gz go-tangerine-99853ac3ce57807deb4822dd324186e1d2ee0821.tar.bz2 go-tangerine-99853ac3ce57807deb4822dd324186e1d2ee0821.tar.lz go-tangerine-99853ac3ce57807deb4822dd324186e1d2ee0821.tar.xz go-tangerine-99853ac3ce57807deb4822dd324186e1d2ee0821.tar.zst go-tangerine-99853ac3ce57807deb4822dd324186e1d2ee0821.zip |
Moved execution from vm to chain.
This moves call and create to the specified environments. Vms are no
longer re-used. Vm uses environment's Call(Code) and Create in order to
execute new contracts or transfer value between accounts.
State transition now uses the same mechanism described above.
Diffstat (limited to 'vm/closure.go')
-rw-r--r-- | vm/closure.go | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/vm/closure.go b/vm/closure.go index 5bd8c1bb8..2263236e7 100644 --- a/vm/closure.go +++ b/vm/closure.go @@ -12,7 +12,7 @@ import ( type ClosureRef interface { ReturnGas(*big.Int, *big.Int) Address() []byte - Object() *state.StateObject + SetCode([]byte) GetStorage(*big.Int) *ethutil.Value SetStorage(*big.Int, *ethutil.Value) } @@ -20,10 +20,9 @@ type ClosureRef interface { // Basic inline closure object which implement the 'closure' interface type Closure struct { caller ClosureRef - object *state.StateObject + object ClosureRef Code []byte message *state.Message - exe *Execution Gas, UsedGas, Price *big.Int @@ -31,7 +30,7 @@ type Closure struct { } // Create a new closure for the given data items -func NewClosure(msg *state.Message, caller ClosureRef, object *state.StateObject, code []byte, gas, price *big.Int) *Closure { +func NewClosure(msg *state.Message, caller ClosureRef, object ClosureRef, code []byte, gas, price *big.Int) *Closure { c := &Closure{message: msg, caller: caller, object: object, Code: code, Args: nil} // Gas should be a pointer so it can safely be reduced through the run @@ -89,6 +88,10 @@ func (c *Closure) Gets(x, y *big.Int) *ethutil.Value { return ethutil.NewValue(partial) } +func (self *Closure) SetCode(code []byte) { + self.Code = code +} + func (c *Closure) SetStorage(x *big.Int, val *ethutil.Value) { c.object.SetStorage(x, val) } @@ -97,6 +100,7 @@ func (c *Closure) Address() []byte { return c.object.Address() } +/* func (c *Closure) Call(vm VirtualMachine, args []byte) ([]byte, *big.Int, error) { c.Args = args @@ -104,6 +108,7 @@ func (c *Closure) Call(vm VirtualMachine, args []byte) ([]byte, *big.Int, error) return ret, c.UsedGas, err } +*/ func (c *Closure) Return(ret []byte) []byte { // Return the remaining gas to the caller @@ -131,14 +136,6 @@ func (c *Closure) ReturnGas(gas, price *big.Int) { c.UsedGas.Sub(c.UsedGas, gas) } -func (c *Closure) Object() *state.StateObject { - return c.object -} - func (c *Closure) Caller() ClosureRef { return c.caller } - -func (self *Closure) SetExecution(exe *Execution) { - self.exe = exe -} |