gitlab.com/aquachain/aquachain@v1.17.16-rc3.0.20221018032414-e3ddf1e1c055/aqua/tracers/tracer_nocgo.go (about)

     1  // Copyright 2018 The aquachain Authors
     2  // This file is part of the aquachain library.
     3  //
     4  // The aquachain library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The aquachain library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the aquachain library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  // +build !gccgo,!cgo
    18  
    19  package tracers
    20  
    21  import (
    22  	"encoding/json"
    23  	"errors"
    24  	"math/big"
    25  	"time"
    26  
    27  	"gitlab.com/aquachain/aquachain/common"
    28  	"gitlab.com/aquachain/aquachain/core/vm"
    29  )
    30  
    31  // Tracer provides an implementation of Tracer that evaluates a Javascript
    32  // function for each VM execution step.
    33  type Tracer struct{}
    34  
    35  var ErrNoCgo = errors.New("This version of aquachain has been compiled with pure go, and has no tracers.")
    36  
    37  // New instantiates a new tracer instance. code specifies a Javascript snippet,
    38  // which must evaluate to an expression returning an object with 'step', 'fault'
    39  // and 'result' functions.
    40  func New(code string) (*Tracer, error) {
    41  	return nil, ErrNoCgo
    42  }
    43  
    44  // Stop terminates execution of the tracer at the first opportune moment.
    45  func (jst *Tracer) Stop(error) {}
    46  
    47  func (jst *Tracer) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) error {
    48  	return ErrNoCgo
    49  }
    50  
    51  // CaptureState implements the Tracer interface to trace a single step of VM execution.
    52  func (jst *Tracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode, gas,
    53  	cost uint64, memory *vm.Memory, stack *vm.Stack,
    54  	contract *vm.Contract, depth int, err error) error {
    55  	return ErrNoCgo
    56  }
    57  
    58  // CaptureFault implements the Tracer interface to trace an execution fault
    59  // while running an opcode.
    60  func (jst *Tracer) CaptureFault(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, memory *vm.Memory, stack *vm.Stack, contract *vm.Contract, depth int, err error) error {
    61  	return ErrNoCgo
    62  }
    63  
    64  // CaptureEnd is called after the call finishes to finalize the tracing.
    65  func (jst *Tracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error {
    66  	return ErrNoCgo
    67  }
    68  
    69  // GetResult calls the Javascript 'result' function and returns its value, or any accumulated error
    70  func (jst *Tracer) GetResult() (json.RawMessage, error) {
    71  	// Transform the context into a JavaScript object and inject into the state
    72  	return json.RawMessage{}, ErrNoCgo
    73  }