-
Notifications
You must be signed in to change notification settings - Fork 4
/
gen_version_record_json.go
45 lines (39 loc) · 1.19 KB
/
gen_version_record_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
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package types
import (
"encoding/json"
"errors"
"github.com/LemoFoundationLtd/lemochain-go/common/hexutil"
)
var _ = (*versionRecordMarshaling)(nil)
// MarshalJSON marshals as JSON.
func (v VersionRecord) MarshalJSON() ([]byte, error) {
type VersionRecord struct {
Version hexutil.Uint32 `json:"version" gencodec:"required"`
Height hexutil.Uint32 `json:"height" gencodec:"required"`
}
var enc VersionRecord
enc.Version = hexutil.Uint32(v.Version)
enc.Height = hexutil.Uint32(v.Height)
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (v *VersionRecord) UnmarshalJSON(input []byte) error {
type VersionRecord struct {
Version *hexutil.Uint32 `json:"version" gencodec:"required"`
Height *hexutil.Uint32 `json:"height" gencodec:"required"`
}
var dec VersionRecord
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
if dec.Version == nil {
return errors.New("missing required field 'version' for VersionRecord")
}
v.Version = uint32(*dec.Version)
if dec.Height == nil {
return errors.New("missing required field 'height' for VersionRecord")
}
v.Height = uint32(*dec.Height)
return nil
}