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