-
Notifications
You must be signed in to change notification settings - Fork 210
/
vault_scale.go
91 lines (87 loc) · 1.66 KB
/
vault_scale.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
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
// Code generated by github.com/spacemeshos/go-scale/scalegen. DO NOT EDIT.
// nolint
package vault
import (
"github.com/spacemeshos/go-scale"
"github.com/spacemeshos/go-spacemesh/common/types"
)
func (t *Vault) EncodeScale(enc *scale.Encoder) (total int, err error) {
{
n, err := scale.EncodeByteArray(enc, t.Owner[:])
if err != nil {
return total, err
}
total += n
}
{
n, err := scale.EncodeCompact64(enc, uint64(t.TotalAmount))
if err != nil {
return total, err
}
total += n
}
{
n, err := scale.EncodeCompact64(enc, uint64(t.InitialUnlockAmount))
if err != nil {
return total, err
}
total += n
}
{
n, err := scale.EncodeCompact32(enc, uint32(t.VestingStart))
if err != nil {
return total, err
}
total += n
}
{
n, err := scale.EncodeCompact32(enc, uint32(t.VestingEnd))
if err != nil {
return total, err
}
total += n
}
return total, nil
}
func (t *Vault) DecodeScale(dec *scale.Decoder) (total int, err error) {
{
n, err := scale.DecodeByteArray(dec, t.Owner[:])
if err != nil {
return total, err
}
total += n
}
{
field, n, err := scale.DecodeCompact64(dec)
if err != nil {
return total, err
}
total += n
t.TotalAmount = uint64(field)
}
{
field, n, err := scale.DecodeCompact64(dec)
if err != nil {
return total, err
}
total += n
t.InitialUnlockAmount = uint64(field)
}
{
field, n, err := scale.DecodeCompact32(dec)
if err != nil {
return total, err
}
total += n
t.VestingStart = types.LayerID(field)
}
{
field, n, err := scale.DecodeCompact32(dec)
if err != nil {
return total, err
}
total += n
t.VestingEnd = types.LayerID(field)
}
return total, nil
}