core/vm: unexported Depth (review change)

This commit is contained in:
Jeffrey Wilcke 2016-12-16 20:06:39 +01:00
parent 64ac1ec1d7
commit 4e777fb7aa
3 changed files with 18 additions and 18 deletions

View file

@ -67,7 +67,7 @@ type EVM struct {
// StateDB gives access to the underlying state
StateDB StateDB
// Depth is the current call stack
Depth int
depth int
// chainConfig contains information about the current chain
chainConfig *params.ChainConfig
@ -113,12 +113,12 @@ func (evm *EVM) init() {
// necessary value transfer required and takes the necessary steps to create accounts and reverses the state in
// case of an execution error or failed value transfer.
func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas, value *big.Int) (ret []byte, err error) {
if evm.Depth == 0 {
if evm.depth == 0 {
evm.init()
defer close(evm.quit)
}
if evm.vmConfig.NoRecursion && evm.Depth > 0 {
if evm.vmConfig.NoRecursion && evm.depth > 0 {
caller.ReturnGas(gas)
return nil, nil
@ -126,7 +126,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas,
// Depth check execution. Fail if we're trying to execute above the
// limit.
if evm.Depth > int(params.CallCreateDepth.Int64()) {
if evm.depth > int(params.CallCreateDepth.Int64()) {
caller.ReturnGas(gas)
return nil, ErrDepth
@ -178,12 +178,12 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas,
//
// CallCode differs from Call in the sense that it executes the given address' code with the caller as context.
func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte, gas, value *big.Int) (ret []byte, err error) {
if evm.Depth == 0 {
if evm.depth == 0 {
evm.init()
defer close(evm.quit)
}
if evm.vmConfig.NoRecursion && evm.Depth > 0 {
if evm.vmConfig.NoRecursion && evm.depth > 0 {
caller.ReturnGas(gas)
return nil, nil
@ -191,7 +191,7 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
// Depth check execution. Fail if we're trying to execute above the
// limit.
if evm.Depth > int(params.CallCreateDepth.Int64()) {
if evm.depth > int(params.CallCreateDepth.Int64()) {
caller.ReturnGas(gas)
return nil, ErrDepth
@ -229,12 +229,12 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
// DelegateCall differs from CallCode in the sense that it executes the given address' code with the caller as context
// and the caller is set to the caller of the caller.
func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []byte, gas *big.Int) (ret []byte, err error) {
if evm.Depth == 0 {
if evm.depth == 0 {
evm.init()
defer close(evm.quit)
}
if evm.vmConfig.NoRecursion && evm.Depth > 0 {
if evm.vmConfig.NoRecursion && evm.depth > 0 {
caller.ReturnGas(gas)
return nil, nil
@ -242,7 +242,7 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
// Depth check execution. Fail if we're trying to execute above the
// limit.
if evm.Depth > int(params.CallCreateDepth.Int64()) {
if evm.depth > int(params.CallCreateDepth.Int64()) {
caller.ReturnGas(gas)
return nil, ErrDepth
}
@ -269,12 +269,12 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
// Create creates a new contract using code as deployment code.
func (evm *EVM) Create(caller ContractRef, code []byte, gas, value *big.Int) (ret []byte, contractAddr common.Address, err error) {
if evm.Depth == 0 {
if evm.depth == 0 {
evm.init()
defer close(evm.quit)
}
if evm.vmConfig.NoRecursion && evm.Depth > 0 {
if evm.vmConfig.NoRecursion && evm.depth > 0 {
caller.ReturnGas(gas)
return nil, common.Address{}, nil
@ -282,7 +282,7 @@ func (evm *EVM) Create(caller ContractRef, code []byte, gas, value *big.Int) (re
// Depth check execution. Fail if we're trying to execute above the
// limit.
if evm.Depth > int(params.CallCreateDepth.Int64()) {
if evm.depth > int(params.CallCreateDepth.Int64()) {
caller.ReturnGas(gas)
return nil, common.Address{}, ErrDepth

View file

@ -155,7 +155,7 @@ func (l *StructLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost *b
}
}
// create a new snaptshot of the EVM.
log := StructLog{pc, op, new(big.Int).Set(gas), cost, mem, stck, storage, env.Depth, err}
log := StructLog{pc, op, new(big.Int).Set(gas), cost, mem, stck, storage, env.depth, err}
l.logs = append(l.logs, log)
return nil

View file

@ -67,8 +67,8 @@ func NewInterpreter(env *EVM, cfg Config) *Interpreter {
// Run loops and evaluates the contract's code with the given input data
func (evm *Interpreter) Run(contract *Contract, input []byte) (ret []byte, err error) {
evm.env.Depth++
defer func() { evm.env.Depth-- }()
evm.env.depth++
defer func() { evm.env.depth-- }()
if contract.CodeAddr != nil {
if p := PrecompiledContracts[*contract.CodeAddr]; p != nil {
@ -100,7 +100,7 @@ func (evm *Interpreter) Run(contract *Contract, input []byte) (ret []byte, err e
// User defer pattern to check for an error and, based on the error being nil or not, use all gas and return.
defer func() {
if err != nil && evm.cfg.Debug {
evm.cfg.Tracer.CaptureState(evm.env, pc, op, contract.Gas, cost, mem, stack, contract, evm.env.Depth, err)
evm.cfg.Tracer.CaptureState(evm.env, pc, op, contract.Gas, cost, mem, stack, contract, evm.env.depth, err)
}
}()
@ -157,7 +157,7 @@ func (evm *Interpreter) Run(contract *Contract, input []byte) (ret []byte, err e
}
if evm.cfg.Debug {
evm.cfg.Tracer.CaptureState(evm.env, pc, op, contract.Gas, cost, mem, stack, contract, evm.env.Depth, err)
evm.cfg.Tracer.CaptureState(evm.env, pc, op, contract.Gas, cost, mem, stack, contract, evm.env.depth, err)
}
// execute the operation