@@ -8,15 +8,15 @@ import (
88 "github.com/ethereum/go-ethereum/state"
99)
1010
11- type ClosureRef interface {
11+ type ContextRef interface {
1212 ReturnGas (* big.Int , * big.Int )
1313 Address () []byte
1414 SetCode ([]byte )
1515}
1616
17- type Closure struct {
18- caller ClosureRef
19- object ClosureRef
17+ type Context struct {
18+ caller ContextRef
19+ object ContextRef
2020 Code []byte
2121 message * state.Message
2222
@@ -25,9 +25,9 @@ type Closure struct {
2525 Args []byte
2626}
2727
28- // Create a new closure for the given data items
29- func NewClosure (msg * state.Message , caller ClosureRef , object ClosureRef , code []byte , gas , price * big.Int ) * Closure {
30- c := & Closure {message : msg , caller : caller , object : object , Code : code , Args : nil }
28+ // Create a new context for the given data items
29+ func NewContext (msg * state.Message , caller ContextRef , object ContextRef , code []byte , gas , price * big.Int ) * Context {
30+ c := & Context {message : msg , caller : caller , object : object , Code : code , Args : nil }
3131
3232 // Gas should be a pointer so it can safely be reduced through the run
3333 // This pointer will be off the state transition
@@ -40,30 +40,30 @@ func NewClosure(msg *state.Message, caller ClosureRef, object ClosureRef, code [
4040 return c
4141}
4242
43- func (c * Closure ) GetOp (x uint64 ) OpCode {
43+ func (c * Context ) GetOp (x uint64 ) OpCode {
4444 return OpCode (c .GetByte (x ))
4545}
4646
47- func (c * Closure ) GetByte (x uint64 ) byte {
47+ func (c * Context ) GetByte (x uint64 ) byte {
4848 if x < uint64 (len (c .Code )) {
4949 return c .Code [x ]
5050 }
5151
5252 return 0
5353}
5454
55- func (c * Closure ) GetBytes (x , y int ) []byte {
55+ func (c * Context ) GetBytes (x , y int ) []byte {
5656 return c .GetRangeValue (uint64 (x ), uint64 (y ))
5757}
5858
59- func (c * Closure ) GetRangeValue (x , size uint64 ) []byte {
59+ func (c * Context ) GetRangeValue (x , size uint64 ) []byte {
6060 x = uint64 (math .Min (float64 (x ), float64 (len (c .Code ))))
6161 y := uint64 (math .Min (float64 (x + size ), float64 (len (c .Code ))))
6262
6363 return ethutil .LeftPadBytes (c .Code [x :y ], int (size ))
6464}
6565
66- func (c * Closure ) Return (ret []byte ) []byte {
66+ func (c * Context ) Return (ret []byte ) []byte {
6767 // Return the remaining gas to the caller
6868 c .caller .ReturnGas (c .Gas , c .Price )
6969
@@ -73,7 +73,7 @@ func (c *Closure) Return(ret []byte) []byte {
7373/*
7474 * Gas functions
7575 */
76- func (c * Closure ) UseGas (gas * big.Int ) bool {
76+ func (c * Context ) UseGas (gas * big.Int ) bool {
7777 if c .Gas .Cmp (gas ) < 0 {
7878 return false
7979 }
@@ -86,19 +86,19 @@ func (c *Closure) UseGas(gas *big.Int) bool {
8686}
8787
8888// Implement the caller interface
89- func (c * Closure ) ReturnGas (gas , price * big.Int ) {
90- // Return the gas to the closure
89+ func (c * Context ) ReturnGas (gas , price * big.Int ) {
90+ // Return the gas to the context
9191 c .Gas .Add (c .Gas , gas )
9292 c .UsedGas .Sub (c .UsedGas , gas )
9393}
9494
9595/*
9696 * Set / Get
9797 */
98- func (c * Closure ) Address () []byte {
98+ func (c * Context ) Address () []byte {
9999 return c .object .Address ()
100100}
101101
102- func (self * Closure ) SetCode (code []byte ) {
102+ func (self * Context ) SetCode (code []byte ) {
103103 self .Code = code
104104}
0 commit comments