github.com/annchain/OG@v0.0.9/p2p/protocol_gen.go (about) 1 package p2p 2 3 // Code generated by github.com/tinylib/msgp DO NOT EDIT. 4 5 import ( 6 "github.com/tinylib/msgp/msgp" 7 ) 8 9 // DecodeMsg implements msgp.Decodable 10 func (z *Cap) DecodeMsg(dc *msgp.Reader) (err error) { 11 var zb0001 uint32 12 zb0001, err = dc.ReadArrayHeader() 13 if err != nil { 14 return 15 } 16 if zb0001 != 2 { 17 err = msgp.ArrayError{Wanted: 2, Got: zb0001} 18 return 19 } 20 z.Name, err = dc.ReadString() 21 if err != nil { 22 return 23 } 24 z.Version, err = dc.ReadUint32() 25 if err != nil { 26 return 27 } 28 return 29 } 30 31 // EncodeMsg implements msgp.Encodable 32 func (z Cap) EncodeMsg(en *msgp.Writer) (err error) { 33 // array header, size 2 34 err = en.Append(0x92) 35 if err != nil { 36 return 37 } 38 err = en.WriteString(z.Name) 39 if err != nil { 40 return 41 } 42 err = en.WriteUint32(z.Version) 43 if err != nil { 44 return 45 } 46 return 47 } 48 49 // MarshalMsg implements msgp.Marshaler 50 func (z Cap) MarshalMsg(b []byte) (o []byte, err error) { 51 o = msgp.Require(b, z.Msgsize()) 52 // array header, size 2 53 o = append(o, 0x92) 54 o = msgp.AppendString(o, z.Name) 55 o = msgp.AppendUint32(o, z.Version) 56 return 57 } 58 59 // UnmarshalMsg implements msgp.Unmarshaler 60 func (z *Cap) UnmarshalMsg(bts []byte) (o []byte, err error) { 61 var zb0001 uint32 62 zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts) 63 if err != nil { 64 return 65 } 66 if zb0001 != 2 { 67 err = msgp.ArrayError{Wanted: 2, Got: zb0001} 68 return 69 } 70 z.Name, bts, err = msgp.ReadStringBytes(bts) 71 if err != nil { 72 return 73 } 74 z.Version, bts, err = msgp.ReadUint32Bytes(bts) 75 if err != nil { 76 return 77 } 78 o = bts 79 return 80 } 81 82 // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message 83 func (z Cap) Msgsize() (s int) { 84 s = 1 + msgp.StringPrefixSize + len(z.Name) + msgp.Uint32Size 85 return 86 } 87 88 // DecodeMsg implements msgp.Decodable 89 func (z *CapsByNameAndVersion) DecodeMsg(dc *msgp.Reader) (err error) { 90 var zb0002 uint32 91 zb0002, err = dc.ReadArrayHeader() 92 if err != nil { 93 return 94 } 95 if cap((*z)) >= int(zb0002) { 96 (*z) = (*z)[:zb0002] 97 } else { 98 (*z) = make(CapsByNameAndVersion, zb0002) 99 } 100 for zb0001 := range *z { 101 var zb0003 uint32 102 zb0003, err = dc.ReadArrayHeader() 103 if err != nil { 104 return 105 } 106 if zb0003 != 2 { 107 err = msgp.ArrayError{Wanted: 2, Got: zb0003} 108 return 109 } 110 (*z)[zb0001].Name, err = dc.ReadString() 111 if err != nil { 112 return 113 } 114 (*z)[zb0001].Version, err = dc.ReadUint32() 115 if err != nil { 116 return 117 } 118 } 119 return 120 } 121 122 // EncodeMsg implements msgp.Encodable 123 func (z CapsByNameAndVersion) EncodeMsg(en *msgp.Writer) (err error) { 124 err = en.WriteArrayHeader(uint32(len(z))) 125 if err != nil { 126 return 127 } 128 for zb0004 := range z { 129 // array header, size 2 130 err = en.Append(0x92) 131 if err != nil { 132 return 133 } 134 err = en.WriteString(z[zb0004].Name) 135 if err != nil { 136 return 137 } 138 err = en.WriteUint32(z[zb0004].Version) 139 if err != nil { 140 return 141 } 142 } 143 return 144 } 145 146 // MarshalMsg implements msgp.Marshaler 147 func (z CapsByNameAndVersion) MarshalMsg(b []byte) (o []byte, err error) { 148 o = msgp.Require(b, z.Msgsize()) 149 o = msgp.AppendArrayHeader(o, uint32(len(z))) 150 for zb0004 := range z { 151 // array header, size 2 152 o = append(o, 0x92) 153 o = msgp.AppendString(o, z[zb0004].Name) 154 o = msgp.AppendUint32(o, z[zb0004].Version) 155 } 156 return 157 } 158 159 // UnmarshalMsg implements msgp.Unmarshaler 160 func (z *CapsByNameAndVersion) UnmarshalMsg(bts []byte) (o []byte, err error) { 161 var zb0002 uint32 162 zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) 163 if err != nil { 164 return 165 } 166 if cap((*z)) >= int(zb0002) { 167 (*z) = (*z)[:zb0002] 168 } else { 169 (*z) = make(CapsByNameAndVersion, zb0002) 170 } 171 for zb0001 := range *z { 172 var zb0003 uint32 173 zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) 174 if err != nil { 175 return 176 } 177 if zb0003 != 2 { 178 err = msgp.ArrayError{Wanted: 2, Got: zb0003} 179 return 180 } 181 (*z)[zb0001].Name, bts, err = msgp.ReadStringBytes(bts) 182 if err != nil { 183 return 184 } 185 (*z)[zb0001].Version, bts, err = msgp.ReadUint32Bytes(bts) 186 if err != nil { 187 return 188 } 189 } 190 o = bts 191 return 192 } 193 194 // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message 195 func (z CapsByNameAndVersion) Msgsize() (s int) { 196 s = msgp.ArrayHeaderSize 197 for zb0004 := range z { 198 s += 1 + msgp.StringPrefixSize + len(z[zb0004].Name) + msgp.Uint32Size 199 } 200 return 201 } 202 203 // DecodeMsg implements msgp.Decodable 204 func (z *MsgCodeType) DecodeMsg(dc *msgp.Reader) (err error) { 205 { 206 var zb0001 uint16 207 zb0001, err = dc.ReadUint16() 208 if err != nil { 209 return 210 } 211 (*z) = MsgCodeType(zb0001) 212 } 213 return 214 } 215 216 // EncodeMsg implements msgp.Encodable 217 func (z MsgCodeType) EncodeMsg(en *msgp.Writer) (err error) { 218 err = en.WriteUint16(uint16(z)) 219 if err != nil { 220 return 221 } 222 return 223 } 224 225 // MarshalMsg implements msgp.Marshaler 226 func (z MsgCodeType) MarshalMsg(b []byte) (o []byte, err error) { 227 o = msgp.Require(b, z.Msgsize()) 228 o = msgp.AppendUint16(o, uint16(z)) 229 return 230 } 231 232 // UnmarshalMsg implements msgp.Unmarshaler 233 func (z *MsgCodeType) UnmarshalMsg(bts []byte) (o []byte, err error) { 234 { 235 var zb0001 uint16 236 zb0001, bts, err = msgp.ReadUint16Bytes(bts) 237 if err != nil { 238 return 239 } 240 (*z) = MsgCodeType(zb0001) 241 } 242 o = bts 243 return 244 } 245 246 // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message 247 func (z MsgCodeType) Msgsize() (s int) { 248 s = msgp.Uint16Size 249 return 250 } 251 252 // DecodeMsg implements msgp.Decodable 253 func (z *ProtoHandshake) DecodeMsg(dc *msgp.Reader) (err error) { 254 var zb0001 uint32 255 zb0001, err = dc.ReadArrayHeader() 256 if err != nil { 257 return 258 } 259 if zb0001 != 5 { 260 err = msgp.ArrayError{Wanted: 5, Got: zb0001} 261 return 262 } 263 z.Version, err = dc.ReadUint32() 264 if err != nil { 265 return 266 } 267 z.Name, err = dc.ReadString() 268 if err != nil { 269 return 270 } 271 var zb0002 uint32 272 zb0002, err = dc.ReadArrayHeader() 273 if err != nil { 274 return 275 } 276 if cap(z.Caps) >= int(zb0002) { 277 z.Caps = (z.Caps)[:zb0002] 278 } else { 279 z.Caps = make([]Cap, zb0002) 280 } 281 for za0001 := range z.Caps { 282 var zb0003 uint32 283 zb0003, err = dc.ReadArrayHeader() 284 if err != nil { 285 return 286 } 287 if zb0003 != 2 { 288 err = msgp.ArrayError{Wanted: 2, Got: zb0003} 289 return 290 } 291 z.Caps[za0001].Name, err = dc.ReadString() 292 if err != nil { 293 return 294 } 295 z.Caps[za0001].Version, err = dc.ReadUint32() 296 if err != nil { 297 return 298 } 299 } 300 z.ListenPort, err = dc.ReadUint16() 301 if err != nil { 302 return 303 } 304 z.ID, err = dc.ReadBytes(z.ID) 305 if err != nil { 306 return 307 } 308 return 309 } 310 311 // EncodeMsg implements msgp.Encodable 312 func (z *ProtoHandshake) EncodeMsg(en *msgp.Writer) (err error) { 313 // array header, size 5 314 err = en.Append(0x95) 315 if err != nil { 316 return 317 } 318 err = en.WriteUint32(z.Version) 319 if err != nil { 320 return 321 } 322 err = en.WriteString(z.Name) 323 if err != nil { 324 return 325 } 326 err = en.WriteArrayHeader(uint32(len(z.Caps))) 327 if err != nil { 328 return 329 } 330 for za0001 := range z.Caps { 331 // array header, size 2 332 err = en.Append(0x92) 333 if err != nil { 334 return 335 } 336 err = en.WriteString(z.Caps[za0001].Name) 337 if err != nil { 338 return 339 } 340 err = en.WriteUint32(z.Caps[za0001].Version) 341 if err != nil { 342 return 343 } 344 } 345 err = en.WriteUint16(z.ListenPort) 346 if err != nil { 347 return 348 } 349 err = en.WriteBytes(z.ID) 350 if err != nil { 351 return 352 } 353 return 354 } 355 356 // MarshalMsg implements msgp.Marshaler 357 func (z *ProtoHandshake) MarshalMsg(b []byte) (o []byte, err error) { 358 o = msgp.Require(b, z.Msgsize()) 359 // array header, size 5 360 o = append(o, 0x95) 361 o = msgp.AppendUint32(o, z.Version) 362 o = msgp.AppendString(o, z.Name) 363 o = msgp.AppendArrayHeader(o, uint32(len(z.Caps))) 364 for za0001 := range z.Caps { 365 // array header, size 2 366 o = append(o, 0x92) 367 o = msgp.AppendString(o, z.Caps[za0001].Name) 368 o = msgp.AppendUint32(o, z.Caps[za0001].Version) 369 } 370 o = msgp.AppendUint16(o, z.ListenPort) 371 o = msgp.AppendBytes(o, z.ID) 372 return 373 } 374 375 // UnmarshalMsg implements msgp.Unmarshaler 376 func (z *ProtoHandshake) UnmarshalMsg(bts []byte) (o []byte, err error) { 377 var zb0001 uint32 378 zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts) 379 if err != nil { 380 return 381 } 382 if zb0001 != 5 { 383 err = msgp.ArrayError{Wanted: 5, Got: zb0001} 384 return 385 } 386 z.Version, bts, err = msgp.ReadUint32Bytes(bts) 387 if err != nil { 388 return 389 } 390 z.Name, bts, err = msgp.ReadStringBytes(bts) 391 if err != nil { 392 return 393 } 394 var zb0002 uint32 395 zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) 396 if err != nil { 397 return 398 } 399 if cap(z.Caps) >= int(zb0002) { 400 z.Caps = (z.Caps)[:zb0002] 401 } else { 402 z.Caps = make([]Cap, zb0002) 403 } 404 for za0001 := range z.Caps { 405 var zb0003 uint32 406 zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) 407 if err != nil { 408 return 409 } 410 if zb0003 != 2 { 411 err = msgp.ArrayError{Wanted: 2, Got: zb0003} 412 return 413 } 414 z.Caps[za0001].Name, bts, err = msgp.ReadStringBytes(bts) 415 if err != nil { 416 return 417 } 418 z.Caps[za0001].Version, bts, err = msgp.ReadUint32Bytes(bts) 419 if err != nil { 420 return 421 } 422 } 423 z.ListenPort, bts, err = msgp.ReadUint16Bytes(bts) 424 if err != nil { 425 return 426 } 427 z.ID, bts, err = msgp.ReadBytesBytes(bts, z.ID) 428 if err != nil { 429 return 430 } 431 o = bts 432 return 433 } 434 435 // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message 436 func (z *ProtoHandshake) Msgsize() (s int) { 437 s = 1 + msgp.Uint32Size + msgp.StringPrefixSize + len(z.Name) + msgp.ArrayHeaderSize 438 for za0001 := range z.Caps { 439 s += 1 + msgp.StringPrefixSize + len(z.Caps[za0001].Name) + msgp.Uint32Size 440 } 441 s += msgp.Uint16Size + msgp.BytesPrefixSize + len(z.ID) 442 return 443 } 444 445 // DecodeMsg implements msgp.Decodable 446 func (z *Protocol) DecodeMsg(dc *msgp.Reader) (err error) { 447 var zb0001 uint32 448 zb0001, err = dc.ReadArrayHeader() 449 if err != nil { 450 return 451 } 452 if zb0001 != 3 { 453 err = msgp.ArrayError{Wanted: 3, Got: zb0001} 454 return 455 } 456 z.Name, err = dc.ReadString() 457 if err != nil { 458 return 459 } 460 z.Version, err = dc.ReadUint32() 461 if err != nil { 462 return 463 } 464 { 465 var zb0002 uint16 466 zb0002, err = dc.ReadUint16() 467 if err != nil { 468 return 469 } 470 z.Length = MsgCodeType(zb0002) 471 } 472 return 473 } 474 475 // EncodeMsg implements msgp.Encodable 476 func (z Protocol) EncodeMsg(en *msgp.Writer) (err error) { 477 // array header, size 3 478 err = en.Append(0x93) 479 if err != nil { 480 return 481 } 482 err = en.WriteString(z.Name) 483 if err != nil { 484 return 485 } 486 err = en.WriteUint32(z.Version) 487 if err != nil { 488 return 489 } 490 err = en.WriteUint16(uint16(z.Length)) 491 if err != nil { 492 return 493 } 494 return 495 } 496 497 // MarshalMsg implements msgp.Marshaler 498 func (z Protocol) MarshalMsg(b []byte) (o []byte, err error) { 499 o = msgp.Require(b, z.Msgsize()) 500 // array header, size 3 501 o = append(o, 0x93) 502 o = msgp.AppendString(o, z.Name) 503 o = msgp.AppendUint32(o, z.Version) 504 o = msgp.AppendUint16(o, uint16(z.Length)) 505 return 506 } 507 508 // UnmarshalMsg implements msgp.Unmarshaler 509 func (z *Protocol) UnmarshalMsg(bts []byte) (o []byte, err error) { 510 var zb0001 uint32 511 zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts) 512 if err != nil { 513 return 514 } 515 if zb0001 != 3 { 516 err = msgp.ArrayError{Wanted: 3, Got: zb0001} 517 return 518 } 519 z.Name, bts, err = msgp.ReadStringBytes(bts) 520 if err != nil { 521 return 522 } 523 z.Version, bts, err = msgp.ReadUint32Bytes(bts) 524 if err != nil { 525 return 526 } 527 { 528 var zb0002 uint16 529 zb0002, bts, err = msgp.ReadUint16Bytes(bts) 530 if err != nil { 531 return 532 } 533 z.Length = MsgCodeType(zb0002) 534 } 535 o = bts 536 return 537 } 538 539 // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message 540 func (z Protocol) Msgsize() (s int) { 541 s = 1 + msgp.StringPrefixSize + len(z.Name) + msgp.Uint32Size + msgp.Uint16Size 542 return 543 }