github.com/codingfuture/orig-energi3@v0.8.4/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/ethereum/go-ethereum/common" 10 "github.com/ethereum/go-ethereum/common/hexutil" 11 "github.com/ethereum/go-ethereum/common/math" 12 "github.com/ethereum/go-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 } 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 return json.Marshal(&enc) 55 } 56 57 // UnmarshalJSON unmarshals from JSON. 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 } 77 var dec btHeader 78 if err := json.Unmarshal(input, &dec); err != nil { 79 return err 80 } 81 if dec.Bloom != nil { 82 b.Bloom = *dec.Bloom 83 } 84 if dec.Coinbase != nil { 85 b.Coinbase = *dec.Coinbase 86 } 87 if dec.MixHash != nil { 88 b.MixHash = *dec.MixHash 89 } 90 if dec.Nonce != nil { 91 b.Nonce = *dec.Nonce 92 } 93 if dec.Number != nil { 94 b.Number = (*big.Int)(dec.Number) 95 } 96 if dec.Hash != nil { 97 b.Hash = *dec.Hash 98 } 99 if dec.ParentHash != nil { 100 b.ParentHash = *dec.ParentHash 101 } 102 if dec.ReceiptTrie != nil { 103 b.ReceiptTrie = *dec.ReceiptTrie 104 } 105 if dec.StateRoot != nil { 106 b.StateRoot = *dec.StateRoot 107 } 108 if dec.TransactionsTrie != nil { 109 b.TransactionsTrie = *dec.TransactionsTrie 110 } 111 if dec.UncleHash != nil { 112 b.UncleHash = *dec.UncleHash 113 } 114 if dec.ExtraData != nil { 115 b.ExtraData = *dec.ExtraData 116 } 117 if dec.Difficulty != nil { 118 b.Difficulty = (*big.Int)(dec.Difficulty) 119 } 120 if dec.GasLimit != nil { 121 b.GasLimit = uint64(*dec.GasLimit) 122 } 123 if dec.GasUsed != nil { 124 b.GasUsed = uint64(*dec.GasUsed) 125 } 126 if dec.Timestamp != nil { 127 b.Timestamp = uint64(*dec.Timestamp) 128 } 129 return nil 130 }