github.com/truechain/go-ethereum@v1.8.11/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  func (s StructLog) MarshalJSON() ([]byte, error) {
    17  	type StructLog struct {
    18  		Pc          uint64                      `json:"pc"`
    19  		Op          OpCode                      `json:"op"`
    20  		Gas         math.HexOrDecimal64         `json:"gas"`
    21  		GasCost     math.HexOrDecimal64         `json:"gasCost"`
    22  		Memory      hexutil.Bytes               `json:"memory"`
    23  		MemorySize  int                         `json:"memSize"`
    24  		Stack       []*math.HexOrDecimal256     `json:"stack"`
    25  		Storage     map[common.Hash]common.Hash `json:"-"`
    26  		Depth       int                         `json:"depth"`
    27  		Err         error                       `json:"-"`
    28  		OpName      string                      `json:"opName"`
    29  		ErrorString string                      `json:"error"`
    30  	}
    31  	var enc StructLog
    32  	enc.Pc = s.Pc
    33  	enc.Op = s.Op
    34  	enc.Gas = math.HexOrDecimal64(s.Gas)
    35  	enc.GasCost = math.HexOrDecimal64(s.GasCost)
    36  	enc.Memory = s.Memory
    37  	enc.MemorySize = s.MemorySize
    38  	if s.Stack != nil {
    39  		enc.Stack = make([]*math.HexOrDecimal256, len(s.Stack))
    40  		for k, v := range s.Stack {
    41  			enc.Stack[k] = (*math.HexOrDecimal256)(v)
    42  		}
    43  	}
    44  	enc.Storage = s.Storage
    45  	enc.Depth = s.Depth
    46  	enc.Err = s.Err
    47  	enc.OpName = s.OpName()
    48  	enc.ErrorString = s.ErrorString()
    49  	return json.Marshal(&enc)
    50  }
    51  
    52  func (s *StructLog) UnmarshalJSON(input []byte) error {
    53  	type StructLog struct {
    54  		Pc         *uint64                     `json:"pc"`
    55  		Op         *OpCode                     `json:"op"`
    56  		Gas        *math.HexOrDecimal64        `json:"gas"`
    57  		GasCost    *math.HexOrDecimal64        `json:"gasCost"`
    58  		Memory     *hexutil.Bytes              `json:"memory"`
    59  		MemorySize *int                        `json:"memSize"`
    60  		Stack      []*math.HexOrDecimal256     `json:"stack"`
    61  		Storage    map[common.Hash]common.Hash `json:"-"`
    62  		Depth      *int                        `json:"depth"`
    63  		Err        error                       `json:"-"`
    64  	}
    65  	var dec StructLog
    66  	if err := json.Unmarshal(input, &dec); err != nil {
    67  		return err
    68  	}
    69  	if dec.Pc != nil {
    70  		s.Pc = *dec.Pc
    71  	}
    72  	if dec.Op != nil {
    73  		s.Op = *dec.Op
    74  	}
    75  	if dec.Gas != nil {
    76  		s.Gas = uint64(*dec.Gas)
    77  	}
    78  	if dec.GasCost != nil {
    79  		s.GasCost = uint64(*dec.GasCost)
    80  	}
    81  	if dec.Memory != nil {
    82  		s.Memory = *dec.Memory
    83  	}
    84  	if dec.MemorySize != nil {
    85  		s.MemorySize = *dec.MemorySize
    86  	}
    87  	if dec.Stack != nil {
    88  		s.Stack = make([]*big.Int, len(dec.Stack))
    89  		for k, v := range dec.Stack {
    90  			s.Stack[k] = (*big.Int)(v)
    91  		}
    92  	}
    93  	if dec.Storage != nil {
    94  		s.Storage = dec.Storage
    95  	}
    96  	if dec.Depth != nil {
    97  		s.Depth = *dec.Depth
    98  	}
    99  	if dec.Err != nil {
   100  		s.Err = dec.Err
   101  	}
   102  	return nil
   103  }