diff options
author | obscuren <geffobscura@gmail.com> | 2014-10-31 21:43:14 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-10-31 21:43:14 +0800 |
commit | af8f5f0b69f1c359991d12c7708804fe8dd1f944 (patch) | |
tree | dd3d5bea8d57037a2d32fae86c4ba7fcc9161b16 /vm | |
parent | 0ed1a8b50a9b9726cd57a2731d0405f6949c6188 (diff) | |
download | go-tangerine-af8f5f0b69f1c359991d12c7708804fe8dd1f944.tar.gz go-tangerine-af8f5f0b69f1c359991d12c7708804fe8dd1f944.tar.zst go-tangerine-af8f5f0b69f1c359991d12c7708804fe8dd1f944.zip |
ethstate => state
Diffstat (limited to 'vm')
-rw-r--r-- | vm/closure.go | 12 | ||||
-rw-r--r-- | vm/debugger.go | 6 | ||||
-rw-r--r-- | vm/environment.go | 6 | ||||
-rw-r--r-- | vm/execution.go | 6 | ||||
-rw-r--r-- | vm/vm_debug.go | 34 |
5 files changed, 32 insertions, 32 deletions
diff --git a/vm/closure.go b/vm/closure.go index b556bc03d..8e54e9ce6 100644 --- a/vm/closure.go +++ b/vm/closure.go @@ -5,14 +5,14 @@ package vm import ( "math/big" - "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" + "github.com/ethereum/go-ethereum/state" ) type ClosureRef interface { ReturnGas(*big.Int, *big.Int) Address() []byte - Object() *ethstate.StateObject + Object() *state.StateObject GetStorage(*big.Int) *ethutil.Value SetStorage(*big.Int, *ethutil.Value) } @@ -20,9 +20,9 @@ type ClosureRef interface { // Basic inline closure object which implement the 'closure' interface type Closure struct { caller ClosureRef - object *ethstate.StateObject + object *state.StateObject Code []byte - message *ethstate.Message + message *state.Message exe *Execution Gas, UsedGas, Price *big.Int @@ -31,7 +31,7 @@ type Closure struct { } // Create a new closure for the given data items -func NewClosure(msg *ethstate.Message, caller ClosureRef, object *ethstate.StateObject, code []byte, gas, price *big.Int) *Closure { +func NewClosure(msg *state.Message, caller ClosureRef, object *state.StateObject, 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 @@ -131,7 +131,7 @@ func (c *Closure) ReturnGas(gas, price *big.Int) { c.UsedGas.Sub(c.UsedGas, gas) } -func (c *Closure) Object() *ethstate.StateObject { +func (c *Closure) Object() *state.StateObject { return c.object } diff --git a/vm/debugger.go b/vm/debugger.go index b0d0e545d..9b08634c6 100644 --- a/vm/debugger.go +++ b/vm/debugger.go @@ -1,10 +1,10 @@ package vm -import "github.com/ethereum/go-ethereum/ethstate" +import "github.com/ethereum/go-ethereum/state" type Debugger interface { - BreakHook(step int, op OpCode, mem *Memory, stack *Stack, object *ethstate.StateObject) bool - StepHook(step int, op OpCode, mem *Memory, stack *Stack, object *ethstate.StateObject) bool + BreakHook(step int, op OpCode, mem *Memory, stack *Stack, object *state.StateObject) bool + StepHook(step int, op OpCode, mem *Memory, stack *Stack, object *state.StateObject) bool BreakPoints() []int64 SetCode(byteCode []byte) } diff --git a/vm/environment.go b/vm/environment.go index deb46b77f..dea86c66c 100644 --- a/vm/environment.go +++ b/vm/environment.go @@ -4,12 +4,12 @@ import ( "errors" "math/big" - "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" + "github.com/ethereum/go-ethereum/state" ) type Environment interface { - State() *ethstate.State + State() *state.State Origin() []byte BlockNumber() *big.Int @@ -20,7 +20,7 @@ type Environment interface { BlockHash() []byte GasLimit() *big.Int Transfer(from, to Account, amount *big.Int) error - AddLog(ethstate.Log) + AddLog(state.Log) } type Object interface { diff --git a/vm/execution.go b/vm/execution.go index 8da0469de..401157808 100644 --- a/vm/execution.go +++ b/vm/execution.go @@ -4,15 +4,15 @@ import ( "fmt" "math/big" - "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" + "github.com/ethereum/go-ethereum/state" ) type Execution struct { vm VirtualMachine address, input []byte Gas, price, value *big.Int - object *ethstate.StateObject + object *state.StateObject SkipTransfer bool } @@ -41,7 +41,7 @@ func (self *Execution) exec(code, caddr []byte, caller ClosureRef) (ret []byte, } }() - msg := env.State().Manifest().AddMessage(ðstate.Message{ + msg := env.State().Manifest().AddMessage(&state.Message{ To: self.address, From: caller.Address(), Input: self.input, Origin: env.Origin(), diff --git a/vm/vm_debug.go b/vm/vm_debug.go index 1cf243e16..0942636d6 100644 --- a/vm/vm_debug.go +++ b/vm/vm_debug.go @@ -5,8 +5,8 @@ import ( "math/big" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" + "github.com/ethereum/go-ethereum/state" ) type DebugVm struct { @@ -49,7 +49,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { pc = big.NewInt(0) step = 0 prevStep = 0 - state = self.env.State() + statedb = self.env.State() require = func(m int) { if stack.Len() < m { panic(fmt.Sprintf("%04v (%v) stack err size = %d, required = %d", pc, op, stack.Len(), m)) @@ -115,7 +115,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { if self.logTy == LogTyDiff { switch op { case STOP, RETURN, SUICIDE: - state.GetStateObject(closure.Address()).EachStorage(func(key string, value *ethutil.Value) { + statedb.GetStateObject(closure.Address()).EachStorage(func(key string, value *ethutil.Value) { value.Decode() fmt.Printf("%x %x\n", new(big.Int).SetBytes([]byte(key)).Bytes(), value.Bytes()) }) @@ -184,7 +184,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { // 0 => non 0 mult = ethutil.Big3 } else if val.BigInt().Cmp(ethutil.Big0) != 0 && len(y.Bytes()) == 0 { - state.Refund(closure.caller.Address(), GasSStoreRefund, closure.Price) + statedb.Refund(closure.caller.Address(), GasSStoreRefund, closure.Price) mult = ethutil.Big0 } else { @@ -532,7 +532,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { case BALANCE: addr := stack.Pop().Bytes() - balance := state.GetBalance(addr) + balance := statedb.GetBalance(addr) stack.Push(balance) @@ -599,7 +599,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { if op == EXTCODESIZE { addr := stack.Pop().Bytes() - code = state.GetCode(addr) + code = statedb.GetCode(addr) } else { code = closure.Code } @@ -613,7 +613,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { if op == EXTCODECOPY { addr := stack.Pop().Bytes() - code = state.GetCode(addr) + code = statedb.GetCode(addr) } else { code = closure.Code } @@ -711,7 +711,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { for i := 0; i < n; i++ { topics[i] = stack.Pop().Bytes() } - self.env.AddLog(ethstate.Log{closure.Address(), topics, data}) + self.env.AddLog(state.Log{closure.Address(), topics, data}) case MLOAD: offset := stack.Pop() val := ethutil.BigD(mem.Get(offset.Int64(), 32)) @@ -733,13 +733,13 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { self.Printf(" => [%v] 0x%x", off, val) case SLOAD: loc := stack.Pop() - val := ethutil.BigD(state.GetState(closure.Address(), loc.Bytes())) + val := ethutil.BigD(statedb.GetState(closure.Address(), loc.Bytes())) stack.Push(val) self.Printf(" {0x%x : 0x%x}", loc.Bytes(), val.Bytes()) case SSTORE: val, loc := stack.Popn() - state.SetState(closure.Address(), loc.Bytes(), val) + statedb.SetState(closure.Address(), loc.Bytes(), val) // Debug sessions are allowed to run without message if closure.message != nil { @@ -784,9 +784,9 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { ) // Generate a new address - n := state.GetNonce(closure.Address()) + n := statedb.GetNonce(closure.Address()) addr := crypto.CreateAddress(closure.Address(), n) - state.SetNonce(closure.Address(), n+1) + statedb.SetNonce(closure.Address(), n+1) self.Printf(" (*) %x", addr).Endl() @@ -861,10 +861,10 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { return closure.Return(ret), nil case SUICIDE: - receiver := state.GetOrNewStateObject(stack.Pop().Bytes()) + receiver := statedb.GetOrNewStateObject(stack.Pop().Bytes()) - receiver.AddAmount(state.GetBalance(closure.Address())) - state.Delete(closure.Address()) + receiver.AddAmount(statedb.GetBalance(closure.Address())) + statedb.Delete(closure.Address()) fallthrough case STOP: // Stop the closure @@ -889,11 +889,11 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { if pc.Cmp(big.NewInt(instrNo)) == 0 { self.Stepping = true - if !self.Dbg.BreakHook(prevStep, op, mem, stack, state.GetStateObject(closure.Address())) { + if !self.Dbg.BreakHook(prevStep, op, mem, stack, statedb.GetStateObject(closure.Address())) { return nil, nil } } else if self.Stepping { - if !self.Dbg.StepHook(prevStep, op, mem, stack, state.GetStateObject(closure.Address())) { + if !self.Dbg.StepHook(prevStep, op, mem, stack, statedb.GetStateObject(closure.Address())) { return nil, nil } } |