github.com/aquanetwork/aquachain@v1.7.8/aqua/tracers/tracer_nocgo.go (about)

     1  // Copyright 2017 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum 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 go-ethereum 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 go-ethereum 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  	return
    47  }
    48  
    49  func (jst *Tracer) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) error {
    50  	return ErrNoCgo
    51  }
    52  
    53  // CaptureState implements the Tracer interface to trace a single step of VM execution.
    54  func (jst *Tracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode, gas,
    55  	cost uint64, memory *vm.Memory, stack *vm.Stack,
    56  	contract *vm.Contract, depth int, err error) error {
    57  	return ErrNoCgo
    58  }
    59  
    60  // CaptureFault implements the Tracer interface to trace an execution fault
    61  // while running an opcode.
    62  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 {
    63  	return ErrNoCgo
    64  }
    65  
    66  // CaptureEnd is called after the call finishes to finalize the tracing.
    67  func (jst *Tracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error {
    68  	return ErrNoCgo
    69  }
    70  
    71  // GetResult calls the Javascript 'result' function and returns its value, or any accumulated error
    72  func (jst *Tracer) GetResult() (json.RawMessage, error) {
    73  	// Transform the context into a JavaScript object and inject into the state
    74  	return json.RawMessage{}, ErrNoCgo
    75  }