github.com/baptiste-b-pegasys/quorum/v22@v22.4.2/core/vm/gen_structlog.go (about)

     1  // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
     2  
     3  package vm
     4  
     5  import (
     6  	"encoding/json"
     7  	"math/big"
     8  
     9  	"github.com/ethereum/go-ethereum/common"
    10  	"github.com/ethereum/go-ethereum/common/hexutil"
    11  	"github.com/ethereum/go-ethereum/common/math"
    12  )
    13  
    14  var _ = (*structLogMarshaling)(nil)
    15  
    16  // MarshalJSON marshals as JSON.
    17  func (s StructLog) MarshalJSON() ([]byte, error) {
    18  	type StructLog struct {
    19  		Pc            uint64                      `json:"pc"`
    20  		Op            OpCode                      `json:"op"`
    21  		Gas           math.HexOrDecimal64         `json:"gas"`
    22  		GasCost       math.HexOrDecimal64         `json:"gasCost"`
    23  		Memory        hexutil.Bytes               `json:"memory"`
    24  		MemorySize    int                         `json:"memSize"`
    25  		Stack         []*math.HexOrDecimal256     `json:"stack"`
    26  		ReturnStack   []math.HexOrDecimal64       `json:"returnStack"`
    27  		ReturnData    hexutil.Bytes               `json:"returnData"`
    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"`
    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  	if s.Stack != nil {
    43  		enc.Stack = make([]*math.HexOrDecimal256, len(s.Stack))
    44  		for k, v := range s.Stack {
    45  			enc.Stack[k] = (*math.HexOrDecimal256)(v)
    46  		}
    47  	}
    48  	enc.ReturnData = s.ReturnData
    49  	enc.Storage = s.Storage
    50  	enc.Depth = s.Depth
    51  	enc.RefundCounter = s.RefundCounter
    52  	enc.Err = s.Err
    53  	enc.OpName = s.OpName()
    54  	enc.ErrorString = s.ErrorString()
    55  	return json.Marshal(&enc)
    56  }
    57  
    58  // UnmarshalJSON unmarshals from JSON.
    59  func (s *StructLog) UnmarshalJSON(input []byte) error {
    60  	type StructLog struct {
    61  		Pc            *uint64                     `json:"pc"`
    62  		Op            *OpCode                     `json:"op"`
    63  		Gas           *math.HexOrDecimal64        `json:"gas"`
    64  		GasCost       *math.HexOrDecimal64        `json:"gasCost"`
    65  		Memory        *hexutil.Bytes              `json:"memory"`
    66  		MemorySize    *int                        `json:"memSize"`
    67  		Stack         []*math.HexOrDecimal256     `json:"stack"`
    68  		ReturnData    *hexutil.Bytes              `json:"returnData"`
    69  		Storage       map[common.Hash]common.Hash `json:"-"`
    70  		Depth         *int                        `json:"depth"`
    71  		RefundCounter *uint64                     `json:"refund"`
    72  		Err           error                       `json:"-"`
    73  	}
    74  	var dec StructLog
    75  	if err := json.Unmarshal(input, &dec); err != nil {
    76  		return err
    77  	}
    78  	if dec.Pc != nil {
    79  		s.Pc = *dec.Pc
    80  	}
    81  	if dec.Op != nil {
    82  		s.Op = *dec.Op
    83  	}
    84  	if dec.Gas != nil {
    85  		s.Gas = uint64(*dec.Gas)
    86  	}
    87  	if dec.GasCost != nil {
    88  		s.GasCost = uint64(*dec.GasCost)
    89  	}
    90  	if dec.Memory != nil {
    91  		s.Memory = *dec.Memory
    92  	}
    93  	if dec.MemorySize != nil {
    94  		s.MemorySize = *dec.MemorySize
    95  	}
    96  	if dec.Stack != nil {
    97  		s.Stack = make([]*big.Int, len(dec.Stack))
    98  		for k, v := range dec.Stack {
    99  			s.Stack[k] = (*big.Int)(v)
   100  		}
   101  	}
   102  	if dec.ReturnData != nil {
   103  		s.ReturnData = *dec.ReturnData
   104  	}
   105  	if dec.Storage != nil {
   106  		s.Storage = dec.Storage
   107  	}
   108  	if dec.Depth != nil {
   109  		s.Depth = *dec.Depth
   110  	}
   111  	if dec.RefundCounter != nil {
   112  		s.RefundCounter = *dec.RefundCounter
   113  	}
   114  	if dec.Err != nil {
   115  		s.Err = dec.Err
   116  	}
   117  	return nil
   118  }