github.com/theQRL/go-zond@v0.1.1/zond/tracers/logger/gen_structlog.go (about)

     1  // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
     2  
     3  package logger
     4  
     5  import (
     6  	"encoding/json"
     7  
     8  	"github.com/theQRL/go-zond/common"
     9  	"github.com/theQRL/go-zond/common/hexutil"
    10  	"github.com/theQRL/go-zond/common/math"
    11  	"github.com/theQRL/go-zond/core/vm"
    12  	"github.com/holiman/uint256"
    13  )
    14  
    15  var _ = (*structLogMarshaling)(nil)
    16  
    17  // MarshalJSON marshals as JSON.
    18  func (s StructLog) MarshalJSON() ([]byte, error) {
    19  	type StructLog struct {
    20  		Pc            uint64                      `json:"pc"`
    21  		Op            vm.OpCode                   `json:"op"`
    22  		Gas           math.HexOrDecimal64         `json:"gas"`
    23  		GasCost       math.HexOrDecimal64         `json:"gasCost"`
    24  		Memory        hexutil.Bytes               `json:"memory,omitempty"`
    25  		MemorySize    int                         `json:"memSize"`
    26  		Stack         []uint256.Int               `json:"stack"`
    27  		ReturnData    hexutil.Bytes               `json:"returnData,omitempty"`
    28  		Storage       map[common.Hash]common.Hash `json:"-"`
    29  		Depth         int                         `json:"depth"`
    30  		RefundCounter uint64                      `json:"refund"`
    31  		Err           error                       `json:"-"`
    32  		OpName        string                      `json:"opName"`
    33  		ErrorString   string                      `json:"error,omitempty"`
    34  	}
    35  	var enc StructLog
    36  	enc.Pc = s.Pc
    37  	enc.Op = s.Op
    38  	enc.Gas = math.HexOrDecimal64(s.Gas)
    39  	enc.GasCost = math.HexOrDecimal64(s.GasCost)
    40  	enc.Memory = s.Memory
    41  	enc.MemorySize = s.MemorySize
    42  	enc.Stack = s.Stack
    43  	enc.ReturnData = s.ReturnData
    44  	enc.Storage = s.Storage
    45  	enc.Depth = s.Depth
    46  	enc.RefundCounter = s.RefundCounter
    47  	enc.Err = s.Err
    48  	enc.OpName = s.OpName()
    49  	enc.ErrorString = s.ErrorString()
    50  	return json.Marshal(&enc)
    51  }
    52  
    53  // UnmarshalJSON unmarshals from JSON.
    54  func (s *StructLog) UnmarshalJSON(input []byte) error {
    55  	type StructLog struct {
    56  		Pc            *uint64                     `json:"pc"`
    57  		Op            *vm.OpCode                  `json:"op"`
    58  		Gas           *math.HexOrDecimal64        `json:"gas"`
    59  		GasCost       *math.HexOrDecimal64        `json:"gasCost"`
    60  		Memory        *hexutil.Bytes              `json:"memory,omitempty"`
    61  		MemorySize    *int                        `json:"memSize"`
    62  		Stack         []uint256.Int               `json:"stack"`
    63  		ReturnData    *hexutil.Bytes              `json:"returnData,omitempty"`
    64  		Storage       map[common.Hash]common.Hash `json:"-"`
    65  		Depth         *int                        `json:"depth"`
    66  		RefundCounter *uint64                     `json:"refund"`
    67  		Err           error                       `json:"-"`
    68  	}
    69  	var dec StructLog
    70  	if err := json.Unmarshal(input, &dec); err != nil {
    71  		return err
    72  	}
    73  	if dec.Pc != nil {
    74  		s.Pc = *dec.Pc
    75  	}
    76  	if dec.Op != nil {
    77  		s.Op = *dec.Op
    78  	}
    79  	if dec.Gas != nil {
    80  		s.Gas = uint64(*dec.Gas)
    81  	}
    82  	if dec.GasCost != nil {
    83  		s.GasCost = uint64(*dec.GasCost)
    84  	}
    85  	if dec.Memory != nil {
    86  		s.Memory = *dec.Memory
    87  	}
    88  	if dec.MemorySize != nil {
    89  		s.MemorySize = *dec.MemorySize
    90  	}
    91  	if dec.Stack != nil {
    92  		s.Stack = dec.Stack
    93  	}
    94  	if dec.ReturnData != nil {
    95  		s.ReturnData = *dec.ReturnData
    96  	}
    97  	if dec.Storage != nil {
    98  		s.Storage = dec.Storage
    99  	}
   100  	if dec.Depth != nil {
   101  		s.Depth = *dec.Depth
   102  	}
   103  	if dec.RefundCounter != nil {
   104  		s.RefundCounter = *dec.RefundCounter
   105  	}
   106  	if dec.Err != nil {
   107  		s.Err = dec.Err
   108  	}
   109  	return nil
   110  }