forked from algorand/go-algorand
-
Notifications
You must be signed in to change notification settings - Fork 0
/
msgp_gen.go
169 lines (160 loc) · 3.82 KB
/
msgp_gen.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
package compactcert
// Code generated by github.com/algorand/msgp DO NOT EDIT.
import (
"github.com/algorand/msgp/msgp"
)
// The following msgp objects are implemented in this file:
// sigFromAddr
// |-----> (*) MarshalMsg
// |-----> (*) CanMarshalMsg
// |-----> (*) UnmarshalMsg
// |-----> (*) CanUnmarshalMsg
// |-----> (*) Msgsize
// |-----> (*) MsgIsZero
//
// MarshalMsg implements msgp.Marshaler
func (z *sigFromAddr) MarshalMsg(b []byte) (o []byte) {
o = msgp.Require(b, z.Msgsize())
// omitempty: check for empty values
zb0001Len := uint32(3)
var zb0001Mask uint8 /* 4 bits */
if (*z).Round.MsgIsZero() {
zb0001Len--
zb0001Mask |= 0x2
}
if (*z).Sig.MsgIsZero() {
zb0001Len--
zb0001Mask |= 0x4
}
if (*z).Signer.MsgIsZero() {
zb0001Len--
zb0001Mask |= 0x8
}
// variable map header, size zb0001Len
o = append(o, 0x80|uint8(zb0001Len))
if zb0001Len != 0 {
if (zb0001Mask & 0x2) == 0 { // if not empty
// string "rnd"
o = append(o, 0xa3, 0x72, 0x6e, 0x64)
o = (*z).Round.MarshalMsg(o)
}
if (zb0001Mask & 0x4) == 0 { // if not empty
// string "sig"
o = append(o, 0xa3, 0x73, 0x69, 0x67)
o = (*z).Sig.MarshalMsg(o)
}
if (zb0001Mask & 0x8) == 0 { // if not empty
// string "signer"
o = append(o, 0xa6, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72)
o = (*z).Signer.MarshalMsg(o)
}
}
return
}
func (_ *sigFromAddr) CanMarshalMsg(z interface{}) bool {
_, ok := (z).(*sigFromAddr)
return ok
}
// UnmarshalMsg implements msgp.Unmarshaler
func (z *sigFromAddr) UnmarshalMsg(bts []byte) (o []byte, err error) {
var field []byte
_ = field
var zb0001 int
var zb0002 bool
zb0001, zb0002, bts, err = msgp.ReadMapHeaderBytes(bts)
if _, ok := err.(msgp.TypeError); ok {
zb0001, zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts)
if err != nil {
err = msgp.WrapError(err)
return
}
if zb0001 > 0 {
zb0001--
bts, err = (*z).Signer.UnmarshalMsg(bts)
if err != nil {
err = msgp.WrapError(err, "struct-from-array", "Signer")
return
}
}
if zb0001 > 0 {
zb0001--
bts, err = (*z).Round.UnmarshalMsg(bts)
if err != nil {
err = msgp.WrapError(err, "struct-from-array", "Round")
return
}
}
if zb0001 > 0 {
zb0001--
bts, err = (*z).Sig.UnmarshalMsg(bts)
if err != nil {
err = msgp.WrapError(err, "struct-from-array", "Sig")
return
}
}
if zb0001 > 0 {
err = msgp.ErrTooManyArrayFields(zb0001)
if err != nil {
err = msgp.WrapError(err, "struct-from-array")
return
}
}
} else {
if err != nil {
err = msgp.WrapError(err)
return
}
if zb0002 {
(*z) = sigFromAddr{}
}
for zb0001 > 0 {
zb0001--
field, bts, err = msgp.ReadMapKeyZC(bts)
if err != nil {
err = msgp.WrapError(err)
return
}
switch string(field) {
case "signer":
bts, err = (*z).Signer.UnmarshalMsg(bts)
if err != nil {
err = msgp.WrapError(err, "Signer")
return
}
case "rnd":
bts, err = (*z).Round.UnmarshalMsg(bts)
if err != nil {
err = msgp.WrapError(err, "Round")
return
}
case "sig":
bts, err = (*z).Sig.UnmarshalMsg(bts)
if err != nil {
err = msgp.WrapError(err, "Sig")
return
}
default:
err = msgp.ErrNoField(string(field))
if err != nil {
err = msgp.WrapError(err)
return
}
}
}
}
o = bts
return
}
func (_ *sigFromAddr) CanUnmarshalMsg(z interface{}) bool {
_, ok := (z).(*sigFromAddr)
return ok
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *sigFromAddr) Msgsize() (s int) {
s = 1 + 7 + (*z).Signer.Msgsize() + 4 + (*z).Round.Msgsize() + 4 + (*z).Sig.Msgsize()
return
}
// MsgIsZero returns whether this is a zero value
func (z *sigFromAddr) MsgIsZero() bool {
return ((*z).Signer.MsgIsZero()) && ((*z).Round.MsgIsZero()) && ((*z).Sig.MsgIsZero())
}