/
gen_btheader.go
100 lines (94 loc) · 2.52 KB
/
gen_btheader.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package tests
import (
"encoding/json"
"math/big"
"github.com/klaytn/klaytn/blockchain/types"
"github.com/klaytn/klaytn/common"
"github.com/klaytn/klaytn/common/hexutil"
"github.com/klaytn/klaytn/common/math"
)
var _ = (*btHeaderMarshaling)(nil)
// MarshalJSON marshals as JSON.
func (b btHeader) MarshalJSON() ([]byte, error) {
type btHeader struct {
Bloom types.Bloom
Number *math.HexOrDecimal256
Hash common.Hash
ParentHash common.Hash
ReceiptTrie common.Hash
StateRoot common.Hash
TransactionsTrie common.Hash
ExtraData hexutil.Bytes
BlockScore *math.HexOrDecimal256
GasUsed math.HexOrDecimal64
Timestamp *math.HexOrDecimal256
}
var enc btHeader
enc.Bloom = b.Bloom
enc.Number = (*math.HexOrDecimal256)(b.Number)
enc.Hash = b.Hash
enc.ParentHash = b.ParentHash
enc.ReceiptTrie = b.ReceiptTrie
enc.StateRoot = b.StateRoot
enc.TransactionsTrie = b.TransactionsTrie
enc.ExtraData = b.ExtraData
enc.BlockScore = (*math.HexOrDecimal256)(b.BlockScore)
enc.GasUsed = math.HexOrDecimal64(b.GasUsed)
enc.Timestamp = (*math.HexOrDecimal256)(b.Timestamp)
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (b *btHeader) UnmarshalJSON(input []byte) error {
type btHeader struct {
Bloom *types.Bloom
Number *math.HexOrDecimal256
Hash *common.Hash
ParentHash *common.Hash
ReceiptTrie *common.Hash
StateRoot *common.Hash
TransactionsTrie *common.Hash
ExtraData *hexutil.Bytes
BlockScore *math.HexOrDecimal256
GasUsed *math.HexOrDecimal64
Timestamp *math.HexOrDecimal256
}
var dec btHeader
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
if dec.Bloom != nil {
b.Bloom = *dec.Bloom
}
if dec.Number != nil {
b.Number = (*big.Int)(dec.Number)
}
if dec.Hash != nil {
b.Hash = *dec.Hash
}
if dec.ParentHash != nil {
b.ParentHash = *dec.ParentHash
}
if dec.ReceiptTrie != nil {
b.ReceiptTrie = *dec.ReceiptTrie
}
if dec.StateRoot != nil {
b.StateRoot = *dec.StateRoot
}
if dec.TransactionsTrie != nil {
b.TransactionsTrie = *dec.TransactionsTrie
}
if dec.ExtraData != nil {
b.ExtraData = *dec.ExtraData
}
if dec.BlockScore != nil {
b.BlockScore = (*big.Int)(dec.BlockScore)
}
if dec.GasUsed != nil {
b.GasUsed = uint64(*dec.GasUsed)
}
if dec.Timestamp != nil {
b.Timestamp = (*big.Int)(dec.Timestamp)
}
return nil
}