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