From 4e777fb7aac8f537301638a8594e400454054e09 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Fri, 16 Dec 2016 20:06:39 +0100 Subject: [PATCH] core/vm: unexported Depth (review change) --- core/vm/environment.go | 26 +++++++++++++------------- core/vm/logger.go | 2 +- core/vm/vm.go | 8 ++++---- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/core/vm/environment.go b/core/vm/environment.go index ffbc123c3f..db3aaa2a4d 100644 --- a/core/vm/environment.go +++ b/core/vm/environment.go @@ -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 diff --git a/core/vm/logger.go b/core/vm/logger.go index 221f06831d..db8c20e07f 100644 --- a/core/vm/logger.go +++ b/core/vm/logger.go @@ -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 diff --git a/core/vm/vm.go b/core/vm/vm.go index e5d5b19920..af0a82a6d3 100644 --- a/core/vm/vm.go +++ b/core/vm/vm.go @@ -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