mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-14 07:53:47 +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
|
Contract *Contract
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MemoryData returns the underlying memory slice. Callers must not modify the contents
|
||||||
|
// of the returned data.
|
||||||
func (ctx *ScopeContext) MemoryData() []byte {
|
func (ctx *ScopeContext) MemoryData() []byte {
|
||||||
if ctx.Memory == nil {
|
if ctx.Memory == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -48,6 +50,8 @@ func (ctx *ScopeContext) MemoryData() []byte {
|
||||||
return ctx.Memory.Data()
|
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 {
|
func (ctx *ScopeContext) StackData() []uint256.Int {
|
||||||
if ctx.Stack == nil {
|
if ctx.Stack == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -55,18 +59,23 @@ func (ctx *ScopeContext) StackData() []uint256.Int {
|
||||||
return ctx.Stack.Data()
|
return ctx.Stack.Data()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Caller returns the current caller.
|
||||||
func (ctx *ScopeContext) Caller() common.Address {
|
func (ctx *ScopeContext) Caller() common.Address {
|
||||||
return ctx.Contract.Caller()
|
return ctx.Contract.Caller()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Address returns the address where this scope of execution is taking place.
|
||||||
func (ctx *ScopeContext) Address() common.Address {
|
func (ctx *ScopeContext) Address() common.Address {
|
||||||
return ctx.Contract.Address()
|
return ctx.Contract.Address()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CallValue returns the value supplied with this call.
|
||||||
func (ctx *ScopeContext) CallValue() *uint256.Int {
|
func (ctx *ScopeContext) CallValue() *uint256.Int {
|
||||||
return ctx.Contract.Value()
|
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 {
|
func (ctx *ScopeContext) CallInput() []byte {
|
||||||
return ctx.Contract.Input
|
return ctx.Contract.Input
|
||||||
}
|
}
|
||||||
|
|
@ -187,15 +196,15 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
contract.Input = input
|
contract.Input = input
|
||||||
|
|
||||||
if debug {
|
if debug {
|
||||||
defer func() {
|
defer func() { // this deferred method handles exit-with-error
|
||||||
if err != nil {
|
if err == nil {
|
||||||
if !logged {
|
return
|
||||||
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))
|
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))
|
||||||
} else if in.evm.Config.Tracer.OnFault != nil {
|
}
|
||||||
in.evm.Config.Tracer.OnFault(pcCopy, byte(op), gasCopy, cost, callContext, 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