github.com/ethereum/go-ethereum@v1.16.1/cmd/evm/internal/t8ntool/gen_execresult.go (about) 1 // Code generated by github.com/fjl/gencodec. DO NOT EDIT. 2 3 package t8ntool 4 5 import ( 6 "encoding/json" 7 "errors" 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 "github.com/ethereum/go-ethereum/core/types" 13 ) 14 15 var _ = (*executionResultMarshaling)(nil) 16 17 // MarshalJSON marshals as JSON. 18 func (e ExecutionResult) MarshalJSON() ([]byte, error) { 19 type ExecutionResult struct { 20 StateRoot common.Hash `json:"stateRoot"` 21 TxRoot common.Hash `json:"txRoot"` 22 ReceiptRoot common.Hash `json:"receiptsRoot"` 23 LogsHash common.Hash `json:"logsHash"` 24 Bloom types.Bloom `json:"logsBloom" gencodec:"required"` 25 Receipts types.Receipts `json:"receipts"` 26 Rejected []*rejectedTx `json:"rejected,omitempty"` 27 Difficulty *math.HexOrDecimal256 `json:"currentDifficulty" gencodec:"required"` 28 GasUsed math.HexOrDecimal64 `json:"gasUsed"` 29 BaseFee *math.HexOrDecimal256 `json:"currentBaseFee,omitempty"` 30 WithdrawalsRoot *common.Hash `json:"withdrawalsRoot,omitempty"` 31 CurrentExcessBlobGas *math.HexOrDecimal64 `json:"currentExcessBlobGas,omitempty"` 32 CurrentBlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed,omitempty"` 33 RequestsHash *common.Hash `json:"requestsHash,omitempty"` 34 Requests []hexutil.Bytes `json:"requests"` 35 } 36 var enc ExecutionResult 37 enc.StateRoot = e.StateRoot 38 enc.TxRoot = e.TxRoot 39 enc.ReceiptRoot = e.ReceiptRoot 40 enc.LogsHash = e.LogsHash 41 enc.Bloom = e.Bloom 42 enc.Receipts = e.Receipts 43 enc.Rejected = e.Rejected 44 enc.Difficulty = e.Difficulty 45 enc.GasUsed = e.GasUsed 46 enc.BaseFee = e.BaseFee 47 enc.WithdrawalsRoot = e.WithdrawalsRoot 48 enc.CurrentExcessBlobGas = e.CurrentExcessBlobGas 49 enc.CurrentBlobGasUsed = e.CurrentBlobGasUsed 50 enc.RequestsHash = e.RequestsHash 51 if e.Requests != nil { 52 enc.Requests = make([]hexutil.Bytes, len(e.Requests)) 53 for k, v := range e.Requests { 54 enc.Requests[k] = v 55 } 56 } 57 return json.Marshal(&enc) 58 } 59 60 // UnmarshalJSON unmarshals from JSON. 61 func (e *ExecutionResult) UnmarshalJSON(input []byte) error { 62 type ExecutionResult struct { 63 StateRoot *common.Hash `json:"stateRoot"` 64 TxRoot *common.Hash `json:"txRoot"` 65 ReceiptRoot *common.Hash `json:"receiptsRoot"` 66 LogsHash *common.Hash `json:"logsHash"` 67 Bloom *types.Bloom `json:"logsBloom" gencodec:"required"` 68 Receipts *types.Receipts `json:"receipts"` 69 Rejected []*rejectedTx `json:"rejected,omitempty"` 70 Difficulty *math.HexOrDecimal256 `json:"currentDifficulty" gencodec:"required"` 71 GasUsed *math.HexOrDecimal64 `json:"gasUsed"` 72 BaseFee *math.HexOrDecimal256 `json:"currentBaseFee,omitempty"` 73 WithdrawalsRoot *common.Hash `json:"withdrawalsRoot,omitempty"` 74 CurrentExcessBlobGas *math.HexOrDecimal64 `json:"currentExcessBlobGas,omitempty"` 75 CurrentBlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed,omitempty"` 76 RequestsHash *common.Hash `json:"requestsHash,omitempty"` 77 Requests []hexutil.Bytes `json:"requests"` 78 } 79 var dec ExecutionResult 80 if err := json.Unmarshal(input, &dec); err != nil { 81 return err 82 } 83 if dec.StateRoot != nil { 84 e.StateRoot = *dec.StateRoot 85 } 86 if dec.TxRoot != nil { 87 e.TxRoot = *dec.TxRoot 88 } 89 if dec.ReceiptRoot != nil { 90 e.ReceiptRoot = *dec.ReceiptRoot 91 } 92 if dec.LogsHash != nil { 93 e.LogsHash = *dec.LogsHash 94 } 95 if dec.Bloom == nil { 96 return errors.New("missing required field 'logsBloom' for ExecutionResult") 97 } 98 e.Bloom = *dec.Bloom 99 if dec.Receipts != nil { 100 e.Receipts = *dec.Receipts 101 } 102 if dec.Rejected != nil { 103 e.Rejected = dec.Rejected 104 } 105 if dec.Difficulty == nil { 106 return errors.New("missing required field 'currentDifficulty' for ExecutionResult") 107 } 108 e.Difficulty = dec.Difficulty 109 if dec.GasUsed != nil { 110 e.GasUsed = *dec.GasUsed 111 } 112 if dec.BaseFee != nil { 113 e.BaseFee = dec.BaseFee 114 } 115 if dec.WithdrawalsRoot != nil { 116 e.WithdrawalsRoot = dec.WithdrawalsRoot 117 } 118 if dec.CurrentExcessBlobGas != nil { 119 e.CurrentExcessBlobGas = dec.CurrentExcessBlobGas 120 } 121 if dec.CurrentBlobGasUsed != nil { 122 e.CurrentBlobGasUsed = dec.CurrentBlobGasUsed 123 } 124 if dec.RequestsHash != nil { 125 e.RequestsHash = dec.RequestsHash 126 } 127 if dec.Requests != nil { 128 e.Requests = make([][]byte, len(dec.Requests)) 129 for k, v := range dec.Requests { 130 e.Requests[k] = v 131 } 132 } 133 return nil 134 }