-
Notifications
You must be signed in to change notification settings - Fork 86
/
gen_difficultytest.go
66 lines (60 loc) · 2.26 KB
/
gen_difficultytest.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
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package tests
import (
"encoding/json"
"math/big"
"github.com/tomochain/tomochain/common"
"github.com/tomochain/tomochain/common/math"
)
var _ = (*difficultyTestMarshaling)(nil)
func (d DifficultyTest) MarshalJSON() ([]byte, error) {
type DifficultyTest struct {
ParentTimestamp *math.HexOrDecimal256 `json:"parentTimestamp"`
ParentDifficulty *math.HexOrDecimal256 `json:"parentDifficulty"`
UncleHash common.Hash `json:"parentUncles"`
CurrentTimestamp *math.HexOrDecimal256 `json:"currentTimestamp"`
CurrentBlockNumber math.HexOrDecimal64 `json:"currentBlockNumber"`
CurrentDifficulty *math.HexOrDecimal256 `json:"currentDifficulty"`
}
var enc DifficultyTest
enc.ParentTimestamp = (*math.HexOrDecimal256)(d.ParentTimestamp)
enc.ParentDifficulty = (*math.HexOrDecimal256)(d.ParentDifficulty)
enc.UncleHash = d.UncleHash
enc.CurrentTimestamp = (*math.HexOrDecimal256)(d.CurrentTimestamp)
enc.CurrentBlockNumber = math.HexOrDecimal64(d.CurrentBlockNumber)
enc.CurrentDifficulty = (*math.HexOrDecimal256)(d.CurrentDifficulty)
return json.Marshal(&enc)
}
func (d *DifficultyTest) UnmarshalJSON(input []byte) error {
type DifficultyTest struct {
ParentTimestamp *math.HexOrDecimal256 `json:"parentTimestamp"`
ParentDifficulty *math.HexOrDecimal256 `json:"parentDifficulty"`
UncleHash *common.Hash `json:"parentUncles"`
CurrentTimestamp *math.HexOrDecimal256 `json:"currentTimestamp"`
CurrentBlockNumber *math.HexOrDecimal64 `json:"currentBlockNumber"`
CurrentDifficulty *math.HexOrDecimal256 `json:"currentDifficulty"`
}
var dec DifficultyTest
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
if dec.ParentTimestamp != nil {
d.ParentTimestamp = (*big.Int)(dec.ParentTimestamp)
}
if dec.ParentDifficulty != nil {
d.ParentDifficulty = (*big.Int)(dec.ParentDifficulty)
}
if dec.UncleHash != nil {
d.UncleHash = *dec.UncleHash
}
if dec.CurrentTimestamp != nil {
d.CurrentTimestamp = (*big.Int)(dec.CurrentTimestamp)
}
if dec.CurrentBlockNumber != nil {
d.CurrentBlockNumber = uint64(*dec.CurrentBlockNumber)
}
if dec.CurrentDifficulty != nil {
d.CurrentDifficulty = (*big.Int)(dec.CurrentDifficulty)
}
return nil
}