mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-30 16:43:46 +00:00
core/vm: documentation + minor refactoring
This commit is contained in:
parent
25051c9ae1
commit
e320d1e1e1
1 changed files with 18 additions and 9 deletions
|
|
@ -41,6 +41,8 @@ type ScopeContext struct {
|
|||
Contract *Contract
|
||||
}
|
||||
|
||||
// MemoryData returns the underlying memory slice. Callers must not modify the contents
|
||||
// of the returned data.
|
||||
func (ctx *ScopeContext) MemoryData() []byte {
|
||||
if ctx.Memory == nil {
|
||||
return nil
|
||||
|
|
@ -48,6 +50,8 @@ func (ctx *ScopeContext) MemoryData() []byte {
|
|||
return ctx.Memory.Data()
|
||||
}
|
||||
|
||||
// MemoryData returns the stack data. Callers must not modify the contents
|
||||
// of the returned data.
|
||||
func (ctx *ScopeContext) StackData() []uint256.Int {
|
||||
if ctx.Stack == nil {
|
||||
return nil
|
||||
|
|
@ -55,18 +59,23 @@ func (ctx *ScopeContext) StackData() []uint256.Int {
|
|||
return ctx.Stack.Data()
|
||||
}
|
||||
|
||||
// Caller returns the current caller.
|
||||
func (ctx *ScopeContext) Caller() common.Address {
|
||||
return ctx.Contract.Caller()
|
||||
}
|
||||
|
||||
// Address returns the address where this scope of execution is taking place.
|
||||
func (ctx *ScopeContext) Address() common.Address {
|
||||
return ctx.Contract.Address()
|
||||
}
|
||||
|
||||
// CallValue returns the value supplied with this call.
|
||||
func (ctx *ScopeContext) CallValue() *uint256.Int {
|
||||
return ctx.Contract.Value()
|
||||
}
|
||||
|
||||
// CallInput returns the input/calldata with this call. Callers must not modify
|
||||
// the contents of the returned data.
|
||||
func (ctx *ScopeContext) CallInput() []byte {
|
||||
return ctx.Contract.Input
|
||||
}
|
||||
|
|
@ -187,15 +196,15 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
|||
contract.Input = input
|
||||
|
||||
if debug {
|
||||
defer func() {
|
||||
if err != nil {
|
||||
if !logged {
|
||||
if in.evm.Config.Tracer.OnOpcode != nil {
|
||||
in.evm.Config.Tracer.OnOpcode(pcCopy, byte(op), gasCopy, cost, callContext, in.returnData, in.evm.depth, VMErrorFromErr(err))
|
||||
}
|
||||
} else if in.evm.Config.Tracer.OnFault != nil {
|
||||
in.evm.Config.Tracer.OnFault(pcCopy, byte(op), gasCopy, cost, callContext, in.evm.depth, VMErrorFromErr(err))
|
||||
}
|
||||
defer func() { // this deferred method handles exit-with-error
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
if !logged && in.evm.Config.Tracer.OnOpcode != nil {
|
||||
in.evm.Config.Tracer.OnOpcode(pcCopy, byte(op), gasCopy, cost, callContext, in.returnData, in.evm.depth, VMErrorFromErr(err))
|
||||
}
|
||||
if logged && in.evm.Config.Tracer.OnFault != nil {
|
||||
in.evm.Config.Tracer.OnFault(pcCopy, byte(op), gasCopy, cost, callContext, in.evm.depth, VMErrorFromErr(err))
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue