github.com/n1ghtfa1l/go-vnt@v0.6.4-alpha.6/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/vntchain/go-vnt/common" 10 "github.com/vntchain/go-vnt/common/hexutil" 11 "github.com/vntchain/go-vnt/common/math" 12 "github.com/vntchain/go-vnt/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 Number *math.HexOrDecimal256 22 Hash common.Hash 23 ParentHash common.Hash 24 ReceiptTrie common.Hash 25 StateRoot common.Hash 26 TransactionsTrie common.Hash 27 ExtraData hexutil.Bytes 28 Difficulty *math.HexOrDecimal256 29 GasLimit math.HexOrDecimal64 30 GasUsed math.HexOrDecimal64 31 Timestamp *math.HexOrDecimal256 32 } 33 var enc btHeader 34 enc.Bloom = b.Bloom 35 enc.Coinbase = b.Coinbase 36 enc.Number = (*math.HexOrDecimal256)(b.Number) 37 enc.Hash = b.Hash 38 enc.ParentHash = b.ParentHash 39 enc.ReceiptTrie = b.ReceiptTrie 40 enc.StateRoot = b.StateRoot 41 enc.TransactionsTrie = b.TransactionsTrie 42 enc.ExtraData = b.ExtraData 43 enc.Difficulty = (*math.HexOrDecimal256)(b.Difficulty) 44 enc.GasLimit = math.HexOrDecimal64(b.GasLimit) 45 enc.GasUsed = math.HexOrDecimal64(b.GasUsed) 46 enc.Timestamp = (*math.HexOrDecimal256)(b.Timestamp) 47 return json.Marshal(&enc) 48 } 49 50 func (b *btHeader) UnmarshalJSON(input []byte) error { 51 type btHeader struct { 52 Bloom *types.Bloom 53 Coinbase *common.Address 54 Number *math.HexOrDecimal256 55 Hash *common.Hash 56 ParentHash *common.Hash 57 ReceiptTrie *common.Hash 58 StateRoot *common.Hash 59 TransactionsTrie *common.Hash 60 ExtraData *hexutil.Bytes 61 Difficulty *math.HexOrDecimal256 62 GasLimit *math.HexOrDecimal64 63 GasUsed *math.HexOrDecimal64 64 Timestamp *math.HexOrDecimal256 65 } 66 var dec btHeader 67 if err := json.Unmarshal(input, &dec); err != nil { 68 return err 69 } 70 if dec.Bloom != nil { 71 b.Bloom = *dec.Bloom 72 } 73 if dec.Coinbase != nil { 74 b.Coinbase = *dec.Coinbase 75 } 76 if dec.Number != nil { 77 b.Number = (*big.Int)(dec.Number) 78 } 79 if dec.Hash != nil { 80 b.Hash = *dec.Hash 81 } 82 if dec.ParentHash != nil { 83 b.ParentHash = *dec.ParentHash 84 } 85 if dec.ReceiptTrie != nil { 86 b.ReceiptTrie = *dec.ReceiptTrie 87 } 88 if dec.StateRoot != nil { 89 b.StateRoot = *dec.StateRoot 90 } 91 if dec.TransactionsTrie != nil { 92 b.TransactionsTrie = *dec.TransactionsTrie 93 } 94 if dec.ExtraData != nil { 95 b.ExtraData = *dec.ExtraData 96 } 97 if dec.Difficulty != nil { 98 b.Difficulty = (*big.Int)(dec.Difficulty) 99 } 100 if dec.GasLimit != nil { 101 b.GasLimit = uint64(*dec.GasLimit) 102 } 103 if dec.GasUsed != nil { 104 b.GasUsed = uint64(*dec.GasUsed) 105 } 106 if dec.Timestamp != nil { 107 b.Timestamp = (*big.Int)(dec.Timestamp) 108 } 109 return nil 110 }