-
Notifications
You must be signed in to change notification settings - Fork 211
/
util_scale.go
61 lines (57 loc) · 1.12 KB
/
util_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
// Code generated by github.com/spacemeshos/go-scale/scalegen. DO NOT EDIT.
// nolint
package proposals
import (
"github.com/spacemeshos/go-scale"
"github.com/spacemeshos/go-spacemesh/common/types"
)
func (t *VrfMessage) EncodeScale(enc *scale.Encoder) (total int, err error) {
{
n, err := scale.EncodeByteArray(enc, t.Beacon[:])
if err != nil {
return total, err
}
total += n
}
{
n, err := scale.EncodeCompact32(enc, uint32(t.Epoch))
if err != nil {
return total, err
}
total += n
}
{
n, err := scale.EncodeCompact32(enc, uint32(t.Counter))
if err != nil {
return total, err
}
total += n
}
return total, nil
}
func (t *VrfMessage) DecodeScale(dec *scale.Decoder) (total int, err error) {
{
n, err := scale.DecodeByteArray(dec, t.Beacon[:])
if err != nil {
return total, err
}
total += n
}
{
field, n, err := scale.DecodeCompact32(dec)
if err != nil {
return total, err
}
total += n
t.Epoch = types.EpochID(field)
}
{
field, n, err := scale.DecodeCompact32(dec)
if err != nil {
return total, err
}
total += n
t.Counter = uint32(field)
}
return total, nil
}