github.com/calmw/ethereum@v0.1.1/tests/gen_btheader.go (about) 1 // Code generated by github.com/fjl/gencodec. DO NOT EDIT. 2 3 package tests 4 5 import ( 6 "encoding/json" 7 "math/big" 8 9 "github.com/calmw/ethereum/common" 10 "github.com/calmw/ethereum/common/hexutil" 11 "github.com/calmw/ethereum/common/math" 12 "github.com/calmw/ethereum/core/types" 13 ) 14 15 var _ = (*btHeaderMarshaling)(nil) 16 17 // MarshalJSON marshals as JSON. 18 func (b btHeader) MarshalJSON() ([]byte, error) { 19 type btHeader struct { 20 Bloom types.Bloom 21 Coinbase common.Address 22 MixHash common.Hash 23 Nonce types.BlockNonce 24 Number *math.HexOrDecimal256 25 Hash common.Hash 26 ParentHash common.Hash 27 ReceiptTrie common.Hash 28 StateRoot common.Hash 29 TransactionsTrie common.Hash 30 UncleHash common.Hash 31 ExtraData hexutil.Bytes 32 Difficulty *math.HexOrDecimal256 33 GasLimit math.HexOrDecimal64 34 GasUsed math.HexOrDecimal64 35 Timestamp math.HexOrDecimal64 36 BaseFeePerGas *math.HexOrDecimal256 37 WithdrawalsRoot *common.Hash 38 } 39 var enc btHeader 40 enc.Bloom = b.Bloom 41 enc.Coinbase = b.Coinbase 42 enc.MixHash = b.MixHash 43 enc.Nonce = b.Nonce 44 enc.Number = (*math.HexOrDecimal256)(b.Number) 45 enc.Hash = b.Hash 46 enc.ParentHash = b.ParentHash 47 enc.ReceiptTrie = b.ReceiptTrie 48 enc.StateRoot = b.StateRoot 49 enc.TransactionsTrie = b.TransactionsTrie 50 enc.UncleHash = b.UncleHash 51 enc.ExtraData = b.ExtraData 52 enc.Difficulty = (*math.HexOrDecimal256)(b.Difficulty) 53 enc.GasLimit = math.HexOrDecimal64(b.GasLimit) 54 enc.GasUsed = math.HexOrDecimal64(b.GasUsed) 55 enc.Timestamp = math.HexOrDecimal64(b.Timestamp) 56 enc.BaseFeePerGas = (*math.HexOrDecimal256)(b.BaseFeePerGas) 57 enc.WithdrawalsRoot = b.WithdrawalsRoot 58 return json.Marshal(&enc) 59 } 60 61 // UnmarshalJSON unmarshals from JSON. 62 func (b *btHeader) UnmarshalJSON(input []byte) error { 63 type btHeader struct { 64 Bloom *types.Bloom 65 Coinbase *common.Address 66 MixHash *common.Hash 67 Nonce *types.BlockNonce 68 Number *math.HexOrDecimal256 69 Hash *common.Hash 70 ParentHash *common.Hash 71 ReceiptTrie *common.Hash 72 StateRoot *common.Hash 73 TransactionsTrie *common.Hash 74 UncleHash *common.Hash 75 ExtraData *hexutil.Bytes 76 Difficulty *math.HexOrDecimal256 77 GasLimit *math.HexOrDecimal64 78 GasUsed *math.HexOrDecimal64 79 Timestamp *math.HexOrDecimal64 80 BaseFeePerGas *math.HexOrDecimal256 81 WithdrawalsRoot *common.Hash 82 } 83 var dec btHeader 84 if err := json.Unmarshal(input, &dec); err != nil { 85 return err 86 } 87 if dec.Bloom != nil { 88 b.Bloom = *dec.Bloom 89 } 90 if dec.Coinbase != nil { 91 b.Coinbase = *dec.Coinbase 92 } 93 if dec.MixHash != nil { 94 b.MixHash = *dec.MixHash 95 } 96 if dec.Nonce != nil { 97 b.Nonce = *dec.Nonce 98 } 99 if dec.Number != nil { 100 b.Number = (*big.Int)(dec.Number) 101 } 102 if dec.Hash != nil { 103 b.Hash = *dec.Hash 104 } 105 if dec.ParentHash != nil { 106 b.ParentHash = *dec.ParentHash 107 } 108 if dec.ReceiptTrie != nil { 109 b.ReceiptTrie = *dec.ReceiptTrie 110 } 111 if dec.StateRoot != nil { 112 b.StateRoot = *dec.StateRoot 113 } 114 if dec.TransactionsTrie != nil { 115 b.TransactionsTrie = *dec.TransactionsTrie 116 } 117 if dec.UncleHash != nil { 118 b.UncleHash = *dec.UncleHash 119 } 120 if dec.ExtraData != nil { 121 b.ExtraData = *dec.ExtraData 122 } 123 if dec.Difficulty != nil { 124 b.Difficulty = (*big.Int)(dec.Difficulty) 125 } 126 if dec.GasLimit != nil { 127 b.GasLimit = uint64(*dec.GasLimit) 128 } 129 if dec.GasUsed != nil { 130 b.GasUsed = uint64(*dec.GasUsed) 131 } 132 if dec.Timestamp != nil { 133 b.Timestamp = uint64(*dec.Timestamp) 134 } 135 if dec.BaseFeePerGas != nil { 136 b.BaseFeePerGas = (*big.Int)(dec.BaseFeePerGas) 137 } 138 if dec.WithdrawalsRoot != nil { 139 b.WithdrawalsRoot = dec.WithdrawalsRoot 140 } 141 return nil 142 }