-
Notifications
You must be signed in to change notification settings - Fork 212
/
oracle_scale.go
76 lines (72 loc) · 1.38 KB
/
oracle_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
// Code generated by github.com/spacemeshos/go-scale/scalegen. DO NOT EDIT.
// nolint
package eligibility
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.EncodeCompact16(enc, uint16(t.Type))
if err != nil {
return total, err
}
total += n
}
{
n, err := scale.EncodeByteArray(enc, t.Beacon[:])
if err != nil {
return total, err
}
total += n
}
{
n, err := scale.EncodeCompact32(enc, uint32(t.Round))
if err != nil {
return total, err
}
total += n
}
{
n, err := scale.EncodeCompact32(enc, uint32(t.Layer))
if err != nil {
return total, err
}
total += n
}
return total, nil
}
func (t *VrfMessage) DecodeScale(dec *scale.Decoder) (total int, err error) {
{
field, n, err := scale.DecodeCompact16(dec)
if err != nil {
return total, err
}
total += n
t.Type = types.EligibilityType(field)
}
{
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.Round = uint32(field)
}
{
field, n, err := scale.DecodeCompact32(dec)
if err != nil {
return total, err
}
total += n
t.Layer = types.LayerID(field)
}
return total, nil
}