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