github.com/FusionFoundation/efsn/v4@v4.2.0/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/FusionFoundation/efsn/v4/common" 10 "github.com/FusionFoundation/efsn/v4/common/hexutil" 11 "github.com/FusionFoundation/efsn/v4/common/math" 12 "github.com/FusionFoundation/efsn/v4/core/types" 13 ) 14 15 var _ = (*btHeaderMarshaling)(nil) 16 17 func (b btHeader) MarshalJSON() ([]byte, error) { 18 type btHeader struct { 19 Bloom types.Bloom 20 Coinbase common.Address 21 MixHash common.Hash 22 Nonce types.BlockNonce 23 Number *math.HexOrDecimal256 24 Hash common.Hash 25 ParentHash common.Hash 26 ReceiptTrie common.Hash 27 StateRoot common.Hash 28 TransactionsTrie common.Hash 29 UncleHash common.Hash 30 ExtraData hexutil.Bytes 31 Difficulty *math.HexOrDecimal256 32 GasLimit math.HexOrDecimal64 33 GasUsed math.HexOrDecimal64 34 Timestamp math.HexOrDecimal64 35 BaseFeePerGas *math.HexOrDecimal256 36 } 37 var enc btHeader 38 enc.Bloom = b.Bloom 39 enc.Coinbase = b.Coinbase 40 enc.MixHash = b.MixHash 41 enc.Nonce = b.Nonce 42 enc.Number = (*math.HexOrDecimal256)(b.Number) 43 enc.Hash = b.Hash 44 enc.ParentHash = b.ParentHash 45 enc.ReceiptTrie = b.ReceiptTrie 46 enc.StateRoot = b.StateRoot 47 enc.TransactionsTrie = b.TransactionsTrie 48 enc.UncleHash = b.UncleHash 49 enc.ExtraData = b.ExtraData 50 enc.Difficulty = (*math.HexOrDecimal256)(b.Difficulty) 51 enc.GasLimit = math.HexOrDecimal64(b.GasLimit) 52 enc.GasUsed = math.HexOrDecimal64(b.GasUsed) 53 enc.Timestamp = math.HexOrDecimal64(b.Timestamp) 54 enc.BaseFeePerGas = (*math.HexOrDecimal256)(b.BaseFeePerGas) 55 return json.Marshal(&enc) 56 } 57 58 func (b *btHeader) UnmarshalJSON(input []byte) error { 59 type btHeader struct { 60 Bloom *types.Bloom 61 Coinbase *common.Address 62 MixHash *common.Hash 63 Nonce *types.BlockNonce 64 Number *math.HexOrDecimal256 65 Hash *common.Hash 66 ParentHash *common.Hash 67 ReceiptTrie *common.Hash 68 StateRoot *common.Hash 69 TransactionsTrie *common.Hash 70 UncleHash *common.Hash 71 ExtraData *hexutil.Bytes 72 Difficulty *math.HexOrDecimal256 73 GasLimit *math.HexOrDecimal64 74 GasUsed *math.HexOrDecimal64 75 Timestamp *math.HexOrDecimal64 76 BaseFeePerGas *math.HexOrDecimal256 77 } 78 var dec btHeader 79 if err := json.Unmarshal(input, &dec); err != nil { 80 return err 81 } 82 if dec.Bloom != nil { 83 b.Bloom = *dec.Bloom 84 } 85 if dec.Coinbase != nil { 86 b.Coinbase = *dec.Coinbase 87 } 88 if dec.MixHash != nil { 89 b.MixHash = *dec.MixHash 90 } 91 if dec.Nonce != nil { 92 b.Nonce = *dec.Nonce 93 } 94 if dec.Number != nil { 95 b.Number = (*big.Int)(dec.Number) 96 } 97 if dec.Hash != nil { 98 b.Hash = *dec.Hash 99 } 100 if dec.ParentHash != nil { 101 b.ParentHash = *dec.ParentHash 102 } 103 if dec.ReceiptTrie != nil { 104 b.ReceiptTrie = *dec.ReceiptTrie 105 } 106 if dec.StateRoot != nil { 107 b.StateRoot = *dec.StateRoot 108 } 109 if dec.TransactionsTrie != nil { 110 b.TransactionsTrie = *dec.TransactionsTrie 111 } 112 if dec.UncleHash != nil { 113 b.UncleHash = *dec.UncleHash 114 } 115 if dec.ExtraData != nil { 116 b.ExtraData = *dec.ExtraData 117 } 118 if dec.Difficulty != nil { 119 b.Difficulty = (*big.Int)(dec.Difficulty) 120 } 121 if dec.GasLimit != nil { 122 b.GasLimit = uint64(*dec.GasLimit) 123 } 124 if dec.GasUsed != nil { 125 b.GasUsed = uint64(*dec.GasUsed) 126 } 127 if dec.Timestamp != nil { 128 b.Timestamp = uint64(*dec.Timestamp) 129 } 130 if dec.BaseFeePerGas != nil { 131 b.BaseFeePerGas = (*big.Int)(dec.BaseFeePerGas) 132 } 133 return nil 134 }