github.com/SmartMeshFoundation/Spectrum@v0.0.0-20220621030607-452a266fee1e/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  	"github.com/SmartMeshFoundation/Spectrum/common"
     8  	"github.com/SmartMeshFoundation/Spectrum/common/hexutil"
     9  	"github.com/SmartMeshFoundation/Spectrum/common/math"
    10  	"github.com/holiman/uint256"
    11  )
    12  
    13  func (s StructLog) MarshalJSON() ([]byte, error) {
    14  	type StructLog struct {
    15  		Pc         uint64                      `json:"pc"`
    16  		Op         OpCode                      `json:"op"`
    17  		Gas        math.HexOrDecimal64         `json:"gas"`
    18  		GasCost    math.HexOrDecimal64         `json:"gasCost"`
    19  		Memory     hexutil.Bytes               `json:"memory"`
    20  		MemorySize int                         `json:"memSize"`
    21  		Stack      []uint256.Int               `json:"stack"`
    22  		Storage    map[common.Hash]common.Hash `json:"-"`
    23  		Depth      int                         `json:"depth"`
    24  		Err        error                       `json:"error"`
    25  		OpName     string                      `json:"opName"`
    26  	}
    27  	var enc StructLog
    28  	enc.Pc = s.Pc
    29  	enc.Op = s.Op
    30  	enc.Gas = math.HexOrDecimal64(s.Gas)
    31  	enc.GasCost = math.HexOrDecimal64(s.GasCost)
    32  	enc.Memory = s.Memory
    33  	enc.MemorySize = s.MemorySize
    34  	enc.Stack = s.Stack
    35  	enc.Storage = s.Storage
    36  	enc.Depth = s.Depth
    37  	enc.Err = s.Err
    38  	enc.OpName = s.OpName()
    39  	return json.Marshal(&enc)
    40  }
    41  
    42  func (s *StructLog) UnmarshalJSON(input []byte) error {
    43  	type StructLog struct {
    44  		Pc         *uint64                     `json:"pc"`
    45  		Op         *OpCode                     `json:"op"`
    46  		Gas        *math.HexOrDecimal64        `json:"gas"`
    47  		GasCost    *math.HexOrDecimal64        `json:"gasCost"`
    48  		Memory     hexutil.Bytes               `json:"memory"`
    49  		MemorySize *int                        `json:"memSize"`
    50  		Stack      []uint256.Int               `json:"stack"`
    51  		Storage    map[common.Hash]common.Hash `json:"-"`
    52  		Depth      *int                        `json:"depth"`
    53  		Err        *error                      `json:"error"`
    54  	}
    55  	var dec StructLog
    56  	if err := json.Unmarshal(input, &dec); err != nil {
    57  		return err
    58  	}
    59  	if dec.Pc != nil {
    60  		s.Pc = *dec.Pc
    61  	}
    62  	if dec.Op != nil {
    63  		s.Op = *dec.Op
    64  	}
    65  	if dec.Gas != nil {
    66  		s.Gas = uint64(*dec.Gas)
    67  	}
    68  	if dec.GasCost != nil {
    69  		s.GasCost = uint64(*dec.GasCost)
    70  	}
    71  	if dec.Memory != nil {
    72  		s.Memory = dec.Memory
    73  	}
    74  	if dec.MemorySize != nil {
    75  		s.MemorySize = *dec.MemorySize
    76  	}
    77  	if dec.Stack != nil {
    78  		s.Stack = dec.Stack
    79  	}
    80  	if dec.Storage != nil {
    81  		s.Storage = dec.Storage
    82  	}
    83  	if dec.Depth != nil {
    84  		s.Depth = *dec.Depth
    85  	}
    86  	if dec.Err != nil {
    87  		s.Err = *dec.Err
    88  	}
    89  	return nil
    90  }