aboutsummaryrefslogtreecommitdiffstats
path: root/tests/gen_btheader.go
blob: 5d65e0dbce797eb04a0a0dece081c85b4509772e (plain) (blame)
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.

package tests

import (
    "encoding/json"
    "math/big"

    "github.com/ethereum/go-ethereum/common"
    "github.com/ethereum/go-ethereum/common/hexutil"
    "github.com/ethereum/go-ethereum/common/math"
    "github.com/ethereum/go-ethereum/core/types"
)

var _ = (*btHeaderMarshaling)(nil)

func (b btHeader) MarshalJSON() ([]byte, error) {
    type btHeader struct {
        Bloom            types.Bloom
        Coinbase         common.Address
        MixHash          common.Hash
        Nonce            types.BlockNonce
        Number           *math.HexOrDecimal256
        Hash             common.Hash
        ParentHash       common.Hash
        ReceiptTrie      common.Hash
        StateRoot        common.Hash
        TransactionsTrie common.Hash
        UncleHash        common.Hash
        ExtraData        hexutil.Bytes
        Difficulty       *math.HexOrDecimal256
        GasLimit         *math.HexOrDecimal256
        GasUsed          *math.HexOrDecimal256
        Timestamp        *math.HexOrDecimal256
    }
    var enc btHeader
    enc.Bloom = b.Bloom
    enc.Coinbase = b.Coinbase
    enc.MixHash = b.MixHash
    enc.Nonce = b.Nonce
    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.UncleHash = b.UncleHash
    enc.ExtraData = b.ExtraData
    enc.Difficulty = (*math.HexOrDecimal256)(b.Difficulty)
    enc.GasLimit = (*math.HexOrDecimal256)(b.GasLimit)
    enc.GasUsed = (*math.HexOrDecimal256)(b.GasUsed)
    enc.Timestamp = (*math.HexOrDecimal256)(b.Timestamp)
    return json.Marshal(&enc)
}

func (b *btHeader) UnmarshalJSON(input []byte) error {
    type btHeader struct {
        Bloom            *types.Bloom
        Coinbase         *common.Address
        MixHash          *common.Hash
        Nonce            *types.BlockNonce
        Number           *math.HexOrDecimal256
        Hash             *common.Hash
        ParentHash       *common.Hash
        ReceiptTrie      *common.Hash
        StateRoot        *common.Hash
        TransactionsTrie *common.Hash
        UncleHash        *common.Hash
        ExtraData        hexutil.Bytes
        Difficulty       *math.HexOrDecimal256
        GasLimit         *math.HexOrDecimal256
        GasUsed          *math.HexOrDecimal256
        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.Coinbase != nil {
        b.Coinbase = *dec.Coinbase
    }
    if dec.MixHash != nil {
        b.MixHash = *dec.MixHash
    }
    if dec.Nonce != nil {
        b.Nonce = *dec.Nonce
    }
    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.UncleHash != nil {
        b.UncleHash = *dec.UncleHash
    }
    if dec.ExtraData != nil {
        b.ExtraData = dec.ExtraData
    }
    if dec.Difficulty != nil {
        b.Difficulty = (*big.Int)(dec.Difficulty)
    }
    if dec.GasLimit != nil {
        b.GasLimit = (*big.Int)(dec.GasLimit)
    }
    if dec.GasUsed != nil {
        b.GasUsed = (*big.Int)(dec.GasUsed)
    }
    if dec.Timestamp != nil {
        b.Timestamp = (*big.Int)(dec.Timestamp)
    }
    return nil
}