-
Notifications
You must be signed in to change notification settings - Fork 4
/
gen_Reward_json.go
53 lines (47 loc) · 1.38 KB
/
gen_Reward_json.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
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package params
import (
"encoding/json"
"errors"
"math/big"
"github.com/LemoFoundationLtd/lemochain-core/common/hexutil"
)
var _ = (*RewardMarshaling)(nil)
// MarshalJSON marshals as JSON.
func (r Reward) MarshalJSON() ([]byte, error) {
type Reward struct {
Term hexutil.Uint32 `json:"term" gencodec:"required"`
Value *hexutil.Big10 `json:"value" gencodec:"required"`
Times hexutil.Uint32 `json:"times" gencodec:"required"`
}
var enc Reward
enc.Term = hexutil.Uint32(r.Term)
enc.Value = (*hexutil.Big10)(r.Value)
enc.Times = hexutil.Uint32(r.Times)
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (r *Reward) UnmarshalJSON(input []byte) error {
type Reward struct {
Term *hexutil.Uint32 `json:"term" gencodec:"required"`
Value *hexutil.Big10 `json:"value" gencodec:"required"`
Times *hexutil.Uint32 `json:"times" gencodec:"required"`
}
var dec Reward
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
if dec.Term == nil {
return errors.New("missing required field 'term' for Reward")
}
r.Term = uint32(*dec.Term)
if dec.Value == nil {
return errors.New("missing required field 'value' for Reward")
}
r.Value = (*big.Int)(dec.Value)
if dec.Times == nil {
return errors.New("missing required field 'times' for Reward")
}
r.Times = uint32(*dec.Times)
return nil
}