github.com/annchain/OG@v0.0.9/consensus/campaign/campaign_gen.go (about) 1 package campaign 2 3 // Code generated by github.com/tinylib/msgp DO NOT EDIT. 4 5 import ( 6 "github.com/annchain/OG/common" 7 "github.com/tinylib/msgp/msgp" 8 ) 9 10 // DecodeMsg implements msgp.Decodable 11 func (z *Campaign) DecodeMsg(dc *msgp.Reader) (err error) { 12 var zb0001 uint32 13 zb0001, err = dc.ReadArrayHeader() 14 if err != nil { 15 err = msgp.WrapError(err) 16 return 17 } 18 if zb0001 != 4 { 19 err = msgp.ArrayError{Wanted: 4, Got: zb0001} 20 return 21 } 22 err = z.TxBase.DecodeMsg(dc) 23 if err != nil { 24 err = msgp.WrapError(err, "TxBase") 25 return 26 } 27 z.DkgPublicKey, err = dc.ReadBytes(z.DkgPublicKey) 28 if err != nil { 29 err = msgp.WrapError(err, "DkgPublicKey") 30 return 31 } 32 err = z.Vrf.DecodeMsg(dc) 33 if err != nil { 34 err = msgp.WrapError(err, "Vrf") 35 return 36 } 37 if dc.IsNil() { 38 err = dc.ReadNil() 39 if err != nil { 40 err = msgp.WrapError(err, "Issuer") 41 return 42 } 43 z.Issuer = nil 44 } else { 45 if z.Issuer == nil { 46 z.Issuer = new(common.Address) 47 } 48 err = z.Issuer.DecodeMsg(dc) 49 if err != nil { 50 err = msgp.WrapError(err, "Issuer") 51 return 52 } 53 } 54 return 55 } 56 57 // EncodeMsg implements msgp.Encodable 58 func (z *Campaign) EncodeMsg(en *msgp.Writer) (err error) { 59 // array header, size 4 60 err = en.Append(0x94) 61 if err != nil { 62 return 63 } 64 err = z.TxBase.EncodeMsg(en) 65 if err != nil { 66 err = msgp.WrapError(err, "TxBase") 67 return 68 } 69 err = en.WriteBytes(z.DkgPublicKey) 70 if err != nil { 71 err = msgp.WrapError(err, "DkgPublicKey") 72 return 73 } 74 err = z.Vrf.EncodeMsg(en) 75 if err != nil { 76 err = msgp.WrapError(err, "Vrf") 77 return 78 } 79 if z.Issuer == nil { 80 err = en.WriteNil() 81 if err != nil { 82 return 83 } 84 } else { 85 err = z.Issuer.EncodeMsg(en) 86 if err != nil { 87 err = msgp.WrapError(err, "Issuer") 88 return 89 } 90 } 91 return 92 } 93 94 // MarshalMsg implements msgp.Marshaler 95 func (z *Campaign) MarshalMsg(b []byte) (o []byte, err error) { 96 o = msgp.Require(b, z.Msgsize()) 97 // array header, size 4 98 o = append(o, 0x94) 99 o, err = z.TxBase.MarshalMsg(o) 100 if err != nil { 101 err = msgp.WrapError(err, "TxBase") 102 return 103 } 104 o = msgp.AppendBytes(o, z.DkgPublicKey) 105 o, err = z.Vrf.MarshalMsg(o) 106 if err != nil { 107 err = msgp.WrapError(err, "Vrf") 108 return 109 } 110 if z.Issuer == nil { 111 o = msgp.AppendNil(o) 112 } else { 113 o, err = z.Issuer.MarshalMsg(o) 114 if err != nil { 115 err = msgp.WrapError(err, "Issuer") 116 return 117 } 118 } 119 return 120 } 121 122 // UnmarshalMsg implements msgp.Unmarshaler 123 func (z *Campaign) UnmarshalMsg(bts []byte) (o []byte, err error) { 124 var zb0001 uint32 125 zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts) 126 if err != nil { 127 err = msgp.WrapError(err) 128 return 129 } 130 if zb0001 != 4 { 131 err = msgp.ArrayError{Wanted: 4, Got: zb0001} 132 return 133 } 134 bts, err = z.TxBase.UnmarshalMsg(bts) 135 if err != nil { 136 err = msgp.WrapError(err, "TxBase") 137 return 138 } 139 z.DkgPublicKey, bts, err = msgp.ReadBytesBytes(bts, z.DkgPublicKey) 140 if err != nil { 141 err = msgp.WrapError(err, "DkgPublicKey") 142 return 143 } 144 bts, err = z.Vrf.UnmarshalMsg(bts) 145 if err != nil { 146 err = msgp.WrapError(err, "Vrf") 147 return 148 } 149 if msgp.IsNil(bts) { 150 bts, err = msgp.ReadNilBytes(bts) 151 if err != nil { 152 return 153 } 154 z.Issuer = nil 155 } else { 156 if z.Issuer == nil { 157 z.Issuer = new(common.Address) 158 } 159 bts, err = z.Issuer.UnmarshalMsg(bts) 160 if err != nil { 161 err = msgp.WrapError(err, "Issuer") 162 return 163 } 164 } 165 o = bts 166 return 167 } 168 169 // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message 170 func (z *Campaign) Msgsize() (s int) { 171 s = 1 + z.TxBase.Msgsize() + msgp.BytesPrefixSize + len(z.DkgPublicKey) + z.Vrf.Msgsize() 172 if z.Issuer == nil { 173 s += msgp.NilSize 174 } else { 175 s += z.Issuer.Msgsize() 176 } 177 return 178 } 179 180 // DecodeMsg implements msgp.Decodable 181 func (z *Campaigns) DecodeMsg(dc *msgp.Reader) (err error) { 182 var zb0002 uint32 183 zb0002, err = dc.ReadArrayHeader() 184 if err != nil { 185 err = msgp.WrapError(err) 186 return 187 } 188 if cap((*z)) >= int(zb0002) { 189 (*z) = (*z)[:zb0002] 190 } else { 191 (*z) = make(Campaigns, zb0002) 192 } 193 for zb0001 := range *z { 194 if dc.IsNil() { 195 err = dc.ReadNil() 196 if err != nil { 197 err = msgp.WrapError(err, zb0001) 198 return 199 } 200 (*z)[zb0001] = nil 201 } else { 202 if (*z)[zb0001] == nil { 203 (*z)[zb0001] = new(Campaign) 204 } 205 err = (*z)[zb0001].DecodeMsg(dc) 206 if err != nil { 207 err = msgp.WrapError(err, zb0001) 208 return 209 } 210 } 211 } 212 return 213 } 214 215 // EncodeMsg implements msgp.Encodable 216 func (z Campaigns) EncodeMsg(en *msgp.Writer) (err error) { 217 err = en.WriteArrayHeader(uint32(len(z))) 218 if err != nil { 219 err = msgp.WrapError(err) 220 return 221 } 222 for zb0003 := range z { 223 if z[zb0003] == nil { 224 err = en.WriteNil() 225 if err != nil { 226 return 227 } 228 } else { 229 err = z[zb0003].EncodeMsg(en) 230 if err != nil { 231 err = msgp.WrapError(err, zb0003) 232 return 233 } 234 } 235 } 236 return 237 } 238 239 // MarshalMsg implements msgp.Marshaler 240 func (z Campaigns) MarshalMsg(b []byte) (o []byte, err error) { 241 o = msgp.Require(b, z.Msgsize()) 242 o = msgp.AppendArrayHeader(o, uint32(len(z))) 243 for zb0003 := range z { 244 if z[zb0003] == nil { 245 o = msgp.AppendNil(o) 246 } else { 247 o, err = z[zb0003].MarshalMsg(o) 248 if err != nil { 249 err = msgp.WrapError(err, zb0003) 250 return 251 } 252 } 253 } 254 return 255 } 256 257 // UnmarshalMsg implements msgp.Unmarshaler 258 func (z *Campaigns) UnmarshalMsg(bts []byte) (o []byte, err error) { 259 var zb0002 uint32 260 zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) 261 if err != nil { 262 err = msgp.WrapError(err) 263 return 264 } 265 if cap((*z)) >= int(zb0002) { 266 (*z) = (*z)[:zb0002] 267 } else { 268 (*z) = make(Campaigns, zb0002) 269 } 270 for zb0001 := range *z { 271 if msgp.IsNil(bts) { 272 bts, err = msgp.ReadNilBytes(bts) 273 if err != nil { 274 return 275 } 276 (*z)[zb0001] = nil 277 } else { 278 if (*z)[zb0001] == nil { 279 (*z)[zb0001] = new(Campaign) 280 } 281 bts, err = (*z)[zb0001].UnmarshalMsg(bts) 282 if err != nil { 283 err = msgp.WrapError(err, zb0001) 284 return 285 } 286 } 287 } 288 o = bts 289 return 290 } 291 292 // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message 293 func (z Campaigns) Msgsize() (s int) { 294 s = msgp.ArrayHeaderSize 295 for zb0003 := range z { 296 if z[zb0003] == nil { 297 s += msgp.NilSize 298 } else { 299 s += z[zb0003].Msgsize() 300 } 301 } 302 return 303 }