github.com/core-coin/go-core/v2@v2.1.9/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/core-coin/go-core/v2/common" 10 "github.com/core-coin/go-core/v2/common/hexutil" 11 "github.com/core-coin/go-core/v2/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 Energy math.HexOrDecimal64 `json:"energy"` 22 EnergyCost math.HexOrDecimal64 `json:"energyCost"` 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.Energy = math.HexOrDecimal64(s.Energy) 39 enc.EnergyCost = math.HexOrDecimal64(s.EnergyCost) 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 if s.ReturnStack != nil { 49 enc.ReturnStack = make([]math.HexOrDecimal64, len(s.ReturnStack)) 50 for k, v := range s.ReturnStack { 51 enc.ReturnStack[k] = math.HexOrDecimal64(v) 52 } 53 } 54 enc.ReturnData = s.ReturnData 55 enc.Storage = s.Storage 56 enc.Depth = s.Depth 57 enc.RefundCounter = s.RefundCounter 58 enc.Err = s.Err 59 enc.OpName = s.OpName() 60 enc.ErrorString = s.ErrorString() 61 return json.Marshal(&enc) 62 } 63 64 // UnmarshalJSON unmarshals from JSON. 65 func (s *StructLog) UnmarshalJSON(input []byte) error { 66 type StructLog struct { 67 Pc *uint64 `json:"pc"` 68 Op *OpCode `json:"op"` 69 Energy *math.HexOrDecimal64 `json:"energy"` 70 EnergyCost *math.HexOrDecimal64 `json:"energyCost"` 71 Memory *hexutil.Bytes `json:"memory"` 72 MemorySize *int `json:"memSize"` 73 Stack []*math.HexOrDecimal256 `json:"stack"` 74 ReturnStack []math.HexOrDecimal64 `json:"returnStack"` 75 ReturnData *hexutil.Bytes `json:"returnData"` 76 Storage map[common.Hash]common.Hash `json:"-"` 77 Depth *int `json:"depth"` 78 RefundCounter *uint64 `json:"refund"` 79 Err error `json:"-"` 80 } 81 var dec StructLog 82 if err := json.Unmarshal(input, &dec); err != nil { 83 return err 84 } 85 if dec.Pc != nil { 86 s.Pc = *dec.Pc 87 } 88 if dec.Op != nil { 89 s.Op = *dec.Op 90 } 91 if dec.Energy != nil { 92 s.Energy = uint64(*dec.Energy) 93 } 94 if dec.EnergyCost != nil { 95 s.EnergyCost = uint64(*dec.EnergyCost) 96 } 97 if dec.Memory != nil { 98 s.Memory = *dec.Memory 99 } 100 if dec.MemorySize != nil { 101 s.MemorySize = *dec.MemorySize 102 } 103 if dec.Stack != nil { 104 s.Stack = make([]*big.Int, len(dec.Stack)) 105 for k, v := range dec.Stack { 106 s.Stack[k] = (*big.Int)(v) 107 } 108 } 109 if dec.ReturnStack != nil { 110 s.ReturnStack = make([]uint32, len(dec.ReturnStack)) 111 for k, v := range dec.ReturnStack { 112 s.ReturnStack[k] = uint32(v) 113 } 114 } 115 if dec.ReturnData != nil { 116 s.ReturnData = *dec.ReturnData 117 } 118 if dec.Storage != nil { 119 s.Storage = dec.Storage 120 } 121 if dec.Depth != nil { 122 s.Depth = *dec.Depth 123 } 124 if dec.RefundCounter != nil { 125 s.RefundCounter = *dec.RefundCounter 126 } 127 if dec.Err != nil { 128 s.Err = dec.Err 129 } 130 return nil 131 }