-
Notifications
You must be signed in to change notification settings - Fork 212
/
activation_scale.go
121 lines (113 loc) · 2.27 KB
/
activation_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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Code generated by github.com/spacemeshos/go-scale/scalegen. DO NOT EDIT.
// nolint
package types
import (
"github.com/spacemeshos/go-scale"
)
func (t *ATXMetadata) EncodeScale(enc *scale.Encoder) (total int, err error) {
{
n, err := scale.EncodeCompact32(enc, uint32(t.PublishEpoch))
if err != nil {
return total, err
}
total += n
}
{
n, err := scale.EncodeByteArray(enc, t.MsgHash[:])
if err != nil {
return total, err
}
total += n
}
return total, nil
}
func (t *ATXMetadata) DecodeScale(dec *scale.Decoder) (total int, err error) {
{
field, n, err := scale.DecodeCompact32(dec)
if err != nil {
return total, err
}
total += n
t.PublishEpoch = EpochID(field)
}
{
n, err := scale.DecodeByteArray(dec, t.MsgHash[:])
if err != nil {
return total, err
}
total += n
}
return total, nil
}
func (t *MerkleProof) EncodeScale(enc *scale.Encoder) (total int, err error) {
{
n, err := scale.EncodeStructSliceWithLimit(enc, t.Nodes, 32)
if err != nil {
return total, err
}
total += n
}
{
n, err := scale.EncodeCompact64(enc, uint64(t.LeafIndex))
if err != nil {
return total, err
}
total += n
}
return total, nil
}
func (t *MerkleProof) DecodeScale(dec *scale.Decoder) (total int, err error) {
{
field, n, err := scale.DecodeStructSliceWithLimit[Hash32](dec, 32)
if err != nil {
return total, err
}
total += n
t.Nodes = field
}
{
field, n, err := scale.DecodeCompact64(dec)
if err != nil {
return total, err
}
total += n
t.LeafIndex = uint64(field)
}
return total, nil
}
func (t *EpochActiveSet) EncodeScale(enc *scale.Encoder) (total int, err error) {
{
n, err := scale.EncodeCompact32(enc, uint32(t.Epoch))
if err != nil {
return total, err
}
total += n
}
{
n, err := scale.EncodeStructSliceWithLimit(enc, t.Set, 4500000)
if err != nil {
return total, err
}
total += n
}
return total, nil
}
func (t *EpochActiveSet) DecodeScale(dec *scale.Decoder) (total int, err error) {
{
field, n, err := scale.DecodeCompact32(dec)
if err != nil {
return total, err
}
total += n
t.Epoch = EpochID(field)
}
{
field, n, err := scale.DecodeStructSliceWithLimit[ATXID](dec, 4500000)
if err != nil {
return total, err
}
total += n
t.Set = field
}
return total, nil
}