github.com/dominant-strategies/go-quai@v0.28.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 8 "github.com/dominant-strategies/go-quai/common" 9 "github.com/dominant-strategies/go-quai/common/hexutil" 10 "github.com/dominant-strategies/go-quai/common/math" 11 "github.com/holiman/uint256" 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 []uint256.Int `json:"stack"` 26 ReturnData hexutil.Bytes `json:"returnData"` 27 Storage map[common.Hash]common.Hash `json:"-"` 28 Depth int `json:"depth"` 29 RefundCounter uint64 `json:"refund"` 30 Err error `json:"-"` 31 OpName string `json:"opName"` 32 ErrorString string `json:"error"` 33 } 34 var enc StructLog 35 enc.Pc = s.Pc 36 enc.Op = s.Op 37 enc.Gas = math.HexOrDecimal64(s.Gas) 38 enc.GasCost = math.HexOrDecimal64(s.GasCost) 39 enc.Memory = s.Memory 40 enc.MemorySize = s.MemorySize 41 enc.Stack = s.Stack 42 enc.ReturnData = s.ReturnData 43 enc.Storage = s.Storage 44 enc.Depth = s.Depth 45 enc.RefundCounter = s.RefundCounter 46 enc.Err = s.Err 47 enc.OpName = s.OpName() 48 enc.ErrorString = s.ErrorString() 49 return json.Marshal(&enc) 50 } 51 52 // UnmarshalJSON unmarshals from JSON. 53 func (s *StructLog) UnmarshalJSON(input []byte) error { 54 type StructLog struct { 55 Pc *uint64 `json:"pc"` 56 Op *OpCode `json:"op"` 57 Gas *math.HexOrDecimal64 `json:"gas"` 58 GasCost *math.HexOrDecimal64 `json:"gasCost"` 59 Memory *hexutil.Bytes `json:"memory"` 60 MemorySize *int `json:"memSize"` 61 Stack []uint256.Int `json:"stack"` 62 ReturnData *hexutil.Bytes `json:"returnData"` 63 Storage map[common.Hash]common.Hash `json:"-"` 64 Depth *int `json:"depth"` 65 RefundCounter *uint64 `json:"refund"` 66 Err error `json:"-"` 67 } 68 var dec StructLog 69 if err := json.Unmarshal(input, &dec); err != nil { 70 return err 71 } 72 if dec.Pc != nil { 73 s.Pc = *dec.Pc 74 } 75 if dec.Op != nil { 76 s.Op = *dec.Op 77 } 78 if dec.Gas != nil { 79 s.Gas = uint64(*dec.Gas) 80 } 81 if dec.GasCost != nil { 82 s.GasCost = uint64(*dec.GasCost) 83 } 84 if dec.Memory != nil { 85 s.Memory = *dec.Memory 86 } 87 if dec.MemorySize != nil { 88 s.MemorySize = *dec.MemorySize 89 } 90 if dec.Stack != nil { 91 s.Stack = dec.Stack 92 } 93 if dec.ReturnData != nil { 94 s.ReturnData = *dec.ReturnData 95 } 96 if dec.Storage != nil { 97 s.Storage = dec.Storage 98 } 99 if dec.Depth != nil { 100 s.Depth = *dec.Depth 101 } 102 if dec.RefundCounter != nil { 103 s.RefundCounter = *dec.RefundCounter 104 } 105 if dec.Err != nil { 106 s.Err = dec.Err 107 } 108 return nil 109 }