2017-09-27 13:30:41 +00:00
|
|
|
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
|
|
|
|
|
|
|
|
package tests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"math/big"
|
|
|
|
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/common/math"
|
2017-09-27 13:30:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ = (*difficultyTestMarshaling)(nil)
|
|
|
|
|
2019-04-02 20:28:48 +00:00
|
|
|
// MarshalJSON marshals as JSON.
|
2017-09-27 13:30:41 +00:00
|
|
|
func (d DifficultyTest) MarshalJSON() ([]byte, error) {
|
|
|
|
type DifficultyTest struct {
|
2019-04-02 20:28:48 +00:00
|
|
|
ParentTimestamp math.HexOrDecimal64 `json:"parentTimestamp"`
|
2017-09-27 13:30:41 +00:00
|
|
|
ParentDifficulty *math.HexOrDecimal256 `json:"parentDifficulty"`
|
2021-12-07 17:24:59 +00:00
|
|
|
ParentUncles math.HexOrDecimal64 `json:"parentUncles"`
|
2019-04-02 20:28:48 +00:00
|
|
|
CurrentTimestamp math.HexOrDecimal64 `json:"currentTimestamp"`
|
2017-09-27 13:30:41 +00:00
|
|
|
CurrentBlockNumber math.HexOrDecimal64 `json:"currentBlockNumber"`
|
|
|
|
CurrentDifficulty *math.HexOrDecimal256 `json:"currentDifficulty"`
|
|
|
|
}
|
|
|
|
var enc DifficultyTest
|
2019-04-02 20:28:48 +00:00
|
|
|
enc.ParentTimestamp = math.HexOrDecimal64(d.ParentTimestamp)
|
2017-09-27 13:30:41 +00:00
|
|
|
enc.ParentDifficulty = (*math.HexOrDecimal256)(d.ParentDifficulty)
|
2021-12-07 17:24:59 +00:00
|
|
|
enc.ParentUncles = math.HexOrDecimal64(d.ParentUncles)
|
2019-04-02 20:28:48 +00:00
|
|
|
enc.CurrentTimestamp = math.HexOrDecimal64(d.CurrentTimestamp)
|
2017-09-27 13:30:41 +00:00
|
|
|
enc.CurrentBlockNumber = math.HexOrDecimal64(d.CurrentBlockNumber)
|
|
|
|
enc.CurrentDifficulty = (*math.HexOrDecimal256)(d.CurrentDifficulty)
|
|
|
|
return json.Marshal(&enc)
|
|
|
|
}
|
|
|
|
|
2019-04-02 20:28:48 +00:00
|
|
|
// UnmarshalJSON unmarshals from JSON.
|
2017-09-27 13:30:41 +00:00
|
|
|
func (d *DifficultyTest) UnmarshalJSON(input []byte) error {
|
|
|
|
type DifficultyTest struct {
|
2019-04-02 20:28:48 +00:00
|
|
|
ParentTimestamp *math.HexOrDecimal64 `json:"parentTimestamp"`
|
2017-09-27 13:30:41 +00:00
|
|
|
ParentDifficulty *math.HexOrDecimal256 `json:"parentDifficulty"`
|
2021-12-07 17:24:59 +00:00
|
|
|
ParentUncles *math.HexOrDecimal64 `json:"parentUncles"`
|
2019-04-02 20:28:48 +00:00
|
|
|
CurrentTimestamp *math.HexOrDecimal64 `json:"currentTimestamp"`
|
2017-09-27 13:30:41 +00:00
|
|
|
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 {
|
2019-04-02 20:28:48 +00:00
|
|
|
d.ParentTimestamp = uint64(*dec.ParentTimestamp)
|
2017-09-27 13:30:41 +00:00
|
|
|
}
|
|
|
|
if dec.ParentDifficulty != nil {
|
|
|
|
d.ParentDifficulty = (*big.Int)(dec.ParentDifficulty)
|
|
|
|
}
|
2021-12-07 17:24:59 +00:00
|
|
|
if dec.ParentUncles != nil {
|
|
|
|
d.ParentUncles = uint64(*dec.ParentUncles)
|
2017-09-27 13:30:41 +00:00
|
|
|
}
|
|
|
|
if dec.CurrentTimestamp != nil {
|
2019-04-02 20:28:48 +00:00
|
|
|
d.CurrentTimestamp = uint64(*dec.CurrentTimestamp)
|
2017-09-27 13:30:41 +00:00
|
|
|
}
|
|
|
|
if dec.CurrentBlockNumber != nil {
|
|
|
|
d.CurrentBlockNumber = uint64(*dec.CurrentBlockNumber)
|
|
|
|
}
|
|
|
|
if dec.CurrentDifficulty != nil {
|
|
|
|
d.CurrentDifficulty = (*big.Int)(dec.CurrentDifficulty)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|