github.1485827954.workers.dev/ethereum/go-ethereum@v1.14.3/eth/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/ethereum/go-ethereum/common" 9 "github.com/ethereum/go-ethereum/common/hexutil" 10 "github.com/ethereum/go-ethereum/common/math" 11 "github.com/ethereum/go-ethereum/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 []hexutil.U256 `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 if s.Stack != nil { 43 enc.Stack = make([]hexutil.U256, len(s.Stack)) 44 for k, v := range s.Stack { 45 enc.Stack[k] = hexutil.U256(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 *vm.OpCode `json:"op"` 63 Gas *math.HexOrDecimal64 `json:"gas"` 64 GasCost *math.HexOrDecimal64 `json:"gasCost"` 65 Memory *hexutil.Bytes `json:"memory,omitempty"` 66 MemorySize *int `json:"memSize"` 67 Stack []hexutil.U256 `json:"stack"` 68 ReturnData *hexutil.Bytes `json:"returnData,omitempty"` 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([]uint256.Int, len(dec.Stack)) 98 for k, v := range dec.Stack { 99 s.Stack[k] = uint256.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 }