github.com/filecoin-project/specs-actors/v4@v4.0.2/actors/builtin/power/cbor_gen.go (about) 1 // Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. 2 3 package power 4 5 import ( 6 "fmt" 7 "io" 8 9 address "github.com/filecoin-project/go-address" 10 abi "github.com/filecoin-project/go-state-types/abi" 11 cbg "github.com/whyrusleeping/cbor-gen" 12 xerrors "golang.org/x/xerrors" 13 ) 14 15 var _ = xerrors.Errorf 16 17 var lengthBufState = []byte{143} 18 19 func (t *State) MarshalCBOR(w io.Writer) error { 20 if t == nil { 21 _, err := w.Write(cbg.CborNull) 22 return err 23 } 24 if _, err := w.Write(lengthBufState); err != nil { 25 return err 26 } 27 28 scratch := make([]byte, 9) 29 30 // t.TotalRawBytePower (big.Int) (struct) 31 if err := t.TotalRawBytePower.MarshalCBOR(w); err != nil { 32 return err 33 } 34 35 // t.TotalBytesCommitted (big.Int) (struct) 36 if err := t.TotalBytesCommitted.MarshalCBOR(w); err != nil { 37 return err 38 } 39 40 // t.TotalQualityAdjPower (big.Int) (struct) 41 if err := t.TotalQualityAdjPower.MarshalCBOR(w); err != nil { 42 return err 43 } 44 45 // t.TotalQABytesCommitted (big.Int) (struct) 46 if err := t.TotalQABytesCommitted.MarshalCBOR(w); err != nil { 47 return err 48 } 49 50 // t.TotalPledgeCollateral (big.Int) (struct) 51 if err := t.TotalPledgeCollateral.MarshalCBOR(w); err != nil { 52 return err 53 } 54 55 // t.ThisEpochRawBytePower (big.Int) (struct) 56 if err := t.ThisEpochRawBytePower.MarshalCBOR(w); err != nil { 57 return err 58 } 59 60 // t.ThisEpochQualityAdjPower (big.Int) (struct) 61 if err := t.ThisEpochQualityAdjPower.MarshalCBOR(w); err != nil { 62 return err 63 } 64 65 // t.ThisEpochPledgeCollateral (big.Int) (struct) 66 if err := t.ThisEpochPledgeCollateral.MarshalCBOR(w); err != nil { 67 return err 68 } 69 70 // t.ThisEpochQAPowerSmoothed (smoothing.FilterEstimate) (struct) 71 if err := t.ThisEpochQAPowerSmoothed.MarshalCBOR(w); err != nil { 72 return err 73 } 74 75 // t.MinerCount (int64) (int64) 76 if t.MinerCount >= 0 { 77 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.MinerCount)); err != nil { 78 return err 79 } 80 } else { 81 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.MinerCount-1)); err != nil { 82 return err 83 } 84 } 85 86 // t.MinerAboveMinPowerCount (int64) (int64) 87 if t.MinerAboveMinPowerCount >= 0 { 88 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.MinerAboveMinPowerCount)); err != nil { 89 return err 90 } 91 } else { 92 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.MinerAboveMinPowerCount-1)); err != nil { 93 return err 94 } 95 } 96 97 // t.CronEventQueue (cid.Cid) (struct) 98 99 if err := cbg.WriteCidBuf(scratch, w, t.CronEventQueue); err != nil { 100 return xerrors.Errorf("failed to write cid field t.CronEventQueue: %w", err) 101 } 102 103 // t.FirstCronEpoch (abi.ChainEpoch) (int64) 104 if t.FirstCronEpoch >= 0 { 105 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.FirstCronEpoch)); err != nil { 106 return err 107 } 108 } else { 109 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.FirstCronEpoch-1)); err != nil { 110 return err 111 } 112 } 113 114 // t.Claims (cid.Cid) (struct) 115 116 if err := cbg.WriteCidBuf(scratch, w, t.Claims); err != nil { 117 return xerrors.Errorf("failed to write cid field t.Claims: %w", err) 118 } 119 120 // t.ProofValidationBatch (cid.Cid) (struct) 121 122 if t.ProofValidationBatch == nil { 123 if _, err := w.Write(cbg.CborNull); err != nil { 124 return err 125 } 126 } else { 127 if err := cbg.WriteCidBuf(scratch, w, *t.ProofValidationBatch); err != nil { 128 return xerrors.Errorf("failed to write cid field t.ProofValidationBatch: %w", err) 129 } 130 } 131 132 return nil 133 } 134 135 func (t *State) UnmarshalCBOR(r io.Reader) error { 136 *t = State{} 137 138 br := cbg.GetPeeker(r) 139 scratch := make([]byte, 8) 140 141 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 142 if err != nil { 143 return err 144 } 145 if maj != cbg.MajArray { 146 return fmt.Errorf("cbor input should be of type array") 147 } 148 149 if extra != 15 { 150 return fmt.Errorf("cbor input had wrong number of fields") 151 } 152 153 // t.TotalRawBytePower (big.Int) (struct) 154 155 { 156 157 if err := t.TotalRawBytePower.UnmarshalCBOR(br); err != nil { 158 return xerrors.Errorf("unmarshaling t.TotalRawBytePower: %w", err) 159 } 160 161 } 162 // t.TotalBytesCommitted (big.Int) (struct) 163 164 { 165 166 if err := t.TotalBytesCommitted.UnmarshalCBOR(br); err != nil { 167 return xerrors.Errorf("unmarshaling t.TotalBytesCommitted: %w", err) 168 } 169 170 } 171 // t.TotalQualityAdjPower (big.Int) (struct) 172 173 { 174 175 if err := t.TotalQualityAdjPower.UnmarshalCBOR(br); err != nil { 176 return xerrors.Errorf("unmarshaling t.TotalQualityAdjPower: %w", err) 177 } 178 179 } 180 // t.TotalQABytesCommitted (big.Int) (struct) 181 182 { 183 184 if err := t.TotalQABytesCommitted.UnmarshalCBOR(br); err != nil { 185 return xerrors.Errorf("unmarshaling t.TotalQABytesCommitted: %w", err) 186 } 187 188 } 189 // t.TotalPledgeCollateral (big.Int) (struct) 190 191 { 192 193 if err := t.TotalPledgeCollateral.UnmarshalCBOR(br); err != nil { 194 return xerrors.Errorf("unmarshaling t.TotalPledgeCollateral: %w", err) 195 } 196 197 } 198 // t.ThisEpochRawBytePower (big.Int) (struct) 199 200 { 201 202 if err := t.ThisEpochRawBytePower.UnmarshalCBOR(br); err != nil { 203 return xerrors.Errorf("unmarshaling t.ThisEpochRawBytePower: %w", err) 204 } 205 206 } 207 // t.ThisEpochQualityAdjPower (big.Int) (struct) 208 209 { 210 211 if err := t.ThisEpochQualityAdjPower.UnmarshalCBOR(br); err != nil { 212 return xerrors.Errorf("unmarshaling t.ThisEpochQualityAdjPower: %w", err) 213 } 214 215 } 216 // t.ThisEpochPledgeCollateral (big.Int) (struct) 217 218 { 219 220 if err := t.ThisEpochPledgeCollateral.UnmarshalCBOR(br); err != nil { 221 return xerrors.Errorf("unmarshaling t.ThisEpochPledgeCollateral: %w", err) 222 } 223 224 } 225 // t.ThisEpochQAPowerSmoothed (smoothing.FilterEstimate) (struct) 226 227 { 228 229 if err := t.ThisEpochQAPowerSmoothed.UnmarshalCBOR(br); err != nil { 230 return xerrors.Errorf("unmarshaling t.ThisEpochQAPowerSmoothed: %w", err) 231 } 232 233 } 234 // t.MinerCount (int64) (int64) 235 { 236 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 237 var extraI int64 238 if err != nil { 239 return err 240 } 241 switch maj { 242 case cbg.MajUnsignedInt: 243 extraI = int64(extra) 244 if extraI < 0 { 245 return fmt.Errorf("int64 positive overflow") 246 } 247 case cbg.MajNegativeInt: 248 extraI = int64(extra) 249 if extraI < 0 { 250 return fmt.Errorf("int64 negative oveflow") 251 } 252 extraI = -1 - extraI 253 default: 254 return fmt.Errorf("wrong type for int64 field: %d", maj) 255 } 256 257 t.MinerCount = int64(extraI) 258 } 259 // t.MinerAboveMinPowerCount (int64) (int64) 260 { 261 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 262 var extraI int64 263 if err != nil { 264 return err 265 } 266 switch maj { 267 case cbg.MajUnsignedInt: 268 extraI = int64(extra) 269 if extraI < 0 { 270 return fmt.Errorf("int64 positive overflow") 271 } 272 case cbg.MajNegativeInt: 273 extraI = int64(extra) 274 if extraI < 0 { 275 return fmt.Errorf("int64 negative oveflow") 276 } 277 extraI = -1 - extraI 278 default: 279 return fmt.Errorf("wrong type for int64 field: %d", maj) 280 } 281 282 t.MinerAboveMinPowerCount = int64(extraI) 283 } 284 // t.CronEventQueue (cid.Cid) (struct) 285 286 { 287 288 c, err := cbg.ReadCid(br) 289 if err != nil { 290 return xerrors.Errorf("failed to read cid field t.CronEventQueue: %w", err) 291 } 292 293 t.CronEventQueue = c 294 295 } 296 // t.FirstCronEpoch (abi.ChainEpoch) (int64) 297 { 298 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 299 var extraI int64 300 if err != nil { 301 return err 302 } 303 switch maj { 304 case cbg.MajUnsignedInt: 305 extraI = int64(extra) 306 if extraI < 0 { 307 return fmt.Errorf("int64 positive overflow") 308 } 309 case cbg.MajNegativeInt: 310 extraI = int64(extra) 311 if extraI < 0 { 312 return fmt.Errorf("int64 negative oveflow") 313 } 314 extraI = -1 - extraI 315 default: 316 return fmt.Errorf("wrong type for int64 field: %d", maj) 317 } 318 319 t.FirstCronEpoch = abi.ChainEpoch(extraI) 320 } 321 // t.Claims (cid.Cid) (struct) 322 323 { 324 325 c, err := cbg.ReadCid(br) 326 if err != nil { 327 return xerrors.Errorf("failed to read cid field t.Claims: %w", err) 328 } 329 330 t.Claims = c 331 332 } 333 // t.ProofValidationBatch (cid.Cid) (struct) 334 335 { 336 337 b, err := br.ReadByte() 338 if err != nil { 339 return err 340 } 341 if b != cbg.CborNull[0] { 342 if err := br.UnreadByte(); err != nil { 343 return err 344 } 345 346 c, err := cbg.ReadCid(br) 347 if err != nil { 348 return xerrors.Errorf("failed to read cid field t.ProofValidationBatch: %w", err) 349 } 350 351 t.ProofValidationBatch = &c 352 } 353 354 } 355 return nil 356 } 357 358 var lengthBufClaim = []byte{131} 359 360 func (t *Claim) MarshalCBOR(w io.Writer) error { 361 if t == nil { 362 _, err := w.Write(cbg.CborNull) 363 return err 364 } 365 if _, err := w.Write(lengthBufClaim); err != nil { 366 return err 367 } 368 369 scratch := make([]byte, 9) 370 371 // t.WindowPoStProofType (abi.RegisteredPoStProof) (int64) 372 if t.WindowPoStProofType >= 0 { 373 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.WindowPoStProofType)); err != nil { 374 return err 375 } 376 } else { 377 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.WindowPoStProofType-1)); err != nil { 378 return err 379 } 380 } 381 382 // t.RawBytePower (big.Int) (struct) 383 if err := t.RawBytePower.MarshalCBOR(w); err != nil { 384 return err 385 } 386 387 // t.QualityAdjPower (big.Int) (struct) 388 if err := t.QualityAdjPower.MarshalCBOR(w); err != nil { 389 return err 390 } 391 return nil 392 } 393 394 func (t *Claim) UnmarshalCBOR(r io.Reader) error { 395 *t = Claim{} 396 397 br := cbg.GetPeeker(r) 398 scratch := make([]byte, 8) 399 400 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 401 if err != nil { 402 return err 403 } 404 if maj != cbg.MajArray { 405 return fmt.Errorf("cbor input should be of type array") 406 } 407 408 if extra != 3 { 409 return fmt.Errorf("cbor input had wrong number of fields") 410 } 411 412 // t.WindowPoStProofType (abi.RegisteredPoStProof) (int64) 413 { 414 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 415 var extraI int64 416 if err != nil { 417 return err 418 } 419 switch maj { 420 case cbg.MajUnsignedInt: 421 extraI = int64(extra) 422 if extraI < 0 { 423 return fmt.Errorf("int64 positive overflow") 424 } 425 case cbg.MajNegativeInt: 426 extraI = int64(extra) 427 if extraI < 0 { 428 return fmt.Errorf("int64 negative oveflow") 429 } 430 extraI = -1 - extraI 431 default: 432 return fmt.Errorf("wrong type for int64 field: %d", maj) 433 } 434 435 t.WindowPoStProofType = abi.RegisteredPoStProof(extraI) 436 } 437 // t.RawBytePower (big.Int) (struct) 438 439 { 440 441 if err := t.RawBytePower.UnmarshalCBOR(br); err != nil { 442 return xerrors.Errorf("unmarshaling t.RawBytePower: %w", err) 443 } 444 445 } 446 // t.QualityAdjPower (big.Int) (struct) 447 448 { 449 450 if err := t.QualityAdjPower.UnmarshalCBOR(br); err != nil { 451 return xerrors.Errorf("unmarshaling t.QualityAdjPower: %w", err) 452 } 453 454 } 455 return nil 456 } 457 458 var lengthBufCronEvent = []byte{130} 459 460 func (t *CronEvent) MarshalCBOR(w io.Writer) error { 461 if t == nil { 462 _, err := w.Write(cbg.CborNull) 463 return err 464 } 465 if _, err := w.Write(lengthBufCronEvent); err != nil { 466 return err 467 } 468 469 scratch := make([]byte, 9) 470 471 // t.MinerAddr (address.Address) (struct) 472 if err := t.MinerAddr.MarshalCBOR(w); err != nil { 473 return err 474 } 475 476 // t.CallbackPayload ([]uint8) (slice) 477 if len(t.CallbackPayload) > cbg.ByteArrayMaxLen { 478 return xerrors.Errorf("Byte array in field t.CallbackPayload was too long") 479 } 480 481 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajByteString, uint64(len(t.CallbackPayload))); err != nil { 482 return err 483 } 484 485 if _, err := w.Write(t.CallbackPayload[:]); err != nil { 486 return err 487 } 488 return nil 489 } 490 491 func (t *CronEvent) UnmarshalCBOR(r io.Reader) error { 492 *t = CronEvent{} 493 494 br := cbg.GetPeeker(r) 495 scratch := make([]byte, 8) 496 497 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 498 if err != nil { 499 return err 500 } 501 if maj != cbg.MajArray { 502 return fmt.Errorf("cbor input should be of type array") 503 } 504 505 if extra != 2 { 506 return fmt.Errorf("cbor input had wrong number of fields") 507 } 508 509 // t.MinerAddr (address.Address) (struct) 510 511 { 512 513 if err := t.MinerAddr.UnmarshalCBOR(br); err != nil { 514 return xerrors.Errorf("unmarshaling t.MinerAddr: %w", err) 515 } 516 517 } 518 // t.CallbackPayload ([]uint8) (slice) 519 520 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 521 if err != nil { 522 return err 523 } 524 525 if extra > cbg.ByteArrayMaxLen { 526 return fmt.Errorf("t.CallbackPayload: byte array too large (%d)", extra) 527 } 528 if maj != cbg.MajByteString { 529 return fmt.Errorf("expected byte array") 530 } 531 532 if extra > 0 { 533 t.CallbackPayload = make([]uint8, extra) 534 } 535 536 if _, err := io.ReadFull(br, t.CallbackPayload[:]); err != nil { 537 return err 538 } 539 return nil 540 } 541 542 var lengthBufCreateMinerParams = []byte{133} 543 544 func (t *CreateMinerParams) MarshalCBOR(w io.Writer) error { 545 if t == nil { 546 _, err := w.Write(cbg.CborNull) 547 return err 548 } 549 if _, err := w.Write(lengthBufCreateMinerParams); err != nil { 550 return err 551 } 552 553 scratch := make([]byte, 9) 554 555 // t.Owner (address.Address) (struct) 556 if err := t.Owner.MarshalCBOR(w); err != nil { 557 return err 558 } 559 560 // t.Worker (address.Address) (struct) 561 if err := t.Worker.MarshalCBOR(w); err != nil { 562 return err 563 } 564 565 // t.WindowPoStProofType (abi.RegisteredPoStProof) (int64) 566 if t.WindowPoStProofType >= 0 { 567 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.WindowPoStProofType)); err != nil { 568 return err 569 } 570 } else { 571 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.WindowPoStProofType-1)); err != nil { 572 return err 573 } 574 } 575 576 // t.Peer ([]uint8) (slice) 577 if len(t.Peer) > cbg.ByteArrayMaxLen { 578 return xerrors.Errorf("Byte array in field t.Peer was too long") 579 } 580 581 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajByteString, uint64(len(t.Peer))); err != nil { 582 return err 583 } 584 585 if _, err := w.Write(t.Peer[:]); err != nil { 586 return err 587 } 588 589 // t.Multiaddrs ([][]uint8) (slice) 590 if len(t.Multiaddrs) > cbg.MaxLength { 591 return xerrors.Errorf("Slice value in field t.Multiaddrs was too long") 592 } 593 594 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Multiaddrs))); err != nil { 595 return err 596 } 597 for _, v := range t.Multiaddrs { 598 if len(v) > cbg.ByteArrayMaxLen { 599 return xerrors.Errorf("Byte array in field v was too long") 600 } 601 602 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajByteString, uint64(len(v))); err != nil { 603 return err 604 } 605 606 if _, err := w.Write(v[:]); err != nil { 607 return err 608 } 609 } 610 return nil 611 } 612 613 func (t *CreateMinerParams) UnmarshalCBOR(r io.Reader) error { 614 *t = CreateMinerParams{} 615 616 br := cbg.GetPeeker(r) 617 scratch := make([]byte, 8) 618 619 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 620 if err != nil { 621 return err 622 } 623 if maj != cbg.MajArray { 624 return fmt.Errorf("cbor input should be of type array") 625 } 626 627 if extra != 5 { 628 return fmt.Errorf("cbor input had wrong number of fields") 629 } 630 631 // t.Owner (address.Address) (struct) 632 633 { 634 635 if err := t.Owner.UnmarshalCBOR(br); err != nil { 636 return xerrors.Errorf("unmarshaling t.Owner: %w", err) 637 } 638 639 } 640 // t.Worker (address.Address) (struct) 641 642 { 643 644 if err := t.Worker.UnmarshalCBOR(br); err != nil { 645 return xerrors.Errorf("unmarshaling t.Worker: %w", err) 646 } 647 648 } 649 // t.WindowPoStProofType (abi.RegisteredPoStProof) (int64) 650 { 651 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 652 var extraI int64 653 if err != nil { 654 return err 655 } 656 switch maj { 657 case cbg.MajUnsignedInt: 658 extraI = int64(extra) 659 if extraI < 0 { 660 return fmt.Errorf("int64 positive overflow") 661 } 662 case cbg.MajNegativeInt: 663 extraI = int64(extra) 664 if extraI < 0 { 665 return fmt.Errorf("int64 negative oveflow") 666 } 667 extraI = -1 - extraI 668 default: 669 return fmt.Errorf("wrong type for int64 field: %d", maj) 670 } 671 672 t.WindowPoStProofType = abi.RegisteredPoStProof(extraI) 673 } 674 // t.Peer ([]uint8) (slice) 675 676 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 677 if err != nil { 678 return err 679 } 680 681 if extra > cbg.ByteArrayMaxLen { 682 return fmt.Errorf("t.Peer: byte array too large (%d)", extra) 683 } 684 if maj != cbg.MajByteString { 685 return fmt.Errorf("expected byte array") 686 } 687 688 if extra > 0 { 689 t.Peer = make([]uint8, extra) 690 } 691 692 if _, err := io.ReadFull(br, t.Peer[:]); err != nil { 693 return err 694 } 695 // t.Multiaddrs ([][]uint8) (slice) 696 697 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 698 if err != nil { 699 return err 700 } 701 702 if extra > cbg.MaxLength { 703 return fmt.Errorf("t.Multiaddrs: array too large (%d)", extra) 704 } 705 706 if maj != cbg.MajArray { 707 return fmt.Errorf("expected cbor array") 708 } 709 710 if extra > 0 { 711 t.Multiaddrs = make([][]uint8, extra) 712 } 713 714 for i := 0; i < int(extra); i++ { 715 { 716 var maj byte 717 var extra uint64 718 var err error 719 720 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 721 if err != nil { 722 return err 723 } 724 725 if extra > cbg.ByteArrayMaxLen { 726 return fmt.Errorf("t.Multiaddrs[i]: byte array too large (%d)", extra) 727 } 728 if maj != cbg.MajByteString { 729 return fmt.Errorf("expected byte array") 730 } 731 732 if extra > 0 { 733 t.Multiaddrs[i] = make([]uint8, extra) 734 } 735 736 if _, err := io.ReadFull(br, t.Multiaddrs[i][:]); err != nil { 737 return err 738 } 739 } 740 } 741 742 return nil 743 } 744 745 var lengthBufCurrentTotalPowerReturn = []byte{132} 746 747 func (t *CurrentTotalPowerReturn) MarshalCBOR(w io.Writer) error { 748 if t == nil { 749 _, err := w.Write(cbg.CborNull) 750 return err 751 } 752 if _, err := w.Write(lengthBufCurrentTotalPowerReturn); err != nil { 753 return err 754 } 755 756 // t.RawBytePower (big.Int) (struct) 757 if err := t.RawBytePower.MarshalCBOR(w); err != nil { 758 return err 759 } 760 761 // t.QualityAdjPower (big.Int) (struct) 762 if err := t.QualityAdjPower.MarshalCBOR(w); err != nil { 763 return err 764 } 765 766 // t.PledgeCollateral (big.Int) (struct) 767 if err := t.PledgeCollateral.MarshalCBOR(w); err != nil { 768 return err 769 } 770 771 // t.QualityAdjPowerSmoothed (smoothing.FilterEstimate) (struct) 772 if err := t.QualityAdjPowerSmoothed.MarshalCBOR(w); err != nil { 773 return err 774 } 775 return nil 776 } 777 778 func (t *CurrentTotalPowerReturn) UnmarshalCBOR(r io.Reader) error { 779 *t = CurrentTotalPowerReturn{} 780 781 br := cbg.GetPeeker(r) 782 scratch := make([]byte, 8) 783 784 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 785 if err != nil { 786 return err 787 } 788 if maj != cbg.MajArray { 789 return fmt.Errorf("cbor input should be of type array") 790 } 791 792 if extra != 4 { 793 return fmt.Errorf("cbor input had wrong number of fields") 794 } 795 796 // t.RawBytePower (big.Int) (struct) 797 798 { 799 800 if err := t.RawBytePower.UnmarshalCBOR(br); err != nil { 801 return xerrors.Errorf("unmarshaling t.RawBytePower: %w", err) 802 } 803 804 } 805 // t.QualityAdjPower (big.Int) (struct) 806 807 { 808 809 if err := t.QualityAdjPower.UnmarshalCBOR(br); err != nil { 810 return xerrors.Errorf("unmarshaling t.QualityAdjPower: %w", err) 811 } 812 813 } 814 // t.PledgeCollateral (big.Int) (struct) 815 816 { 817 818 if err := t.PledgeCollateral.UnmarshalCBOR(br); err != nil { 819 return xerrors.Errorf("unmarshaling t.PledgeCollateral: %w", err) 820 } 821 822 } 823 // t.QualityAdjPowerSmoothed (smoothing.FilterEstimate) (struct) 824 825 { 826 827 if err := t.QualityAdjPowerSmoothed.UnmarshalCBOR(br); err != nil { 828 return xerrors.Errorf("unmarshaling t.QualityAdjPowerSmoothed: %w", err) 829 } 830 831 } 832 return nil 833 } 834 835 var lengthBufMinerConstructorParams = []byte{134} 836 837 func (t *MinerConstructorParams) MarshalCBOR(w io.Writer) error { 838 if t == nil { 839 _, err := w.Write(cbg.CborNull) 840 return err 841 } 842 if _, err := w.Write(lengthBufMinerConstructorParams); err != nil { 843 return err 844 } 845 846 scratch := make([]byte, 9) 847 848 // t.OwnerAddr (address.Address) (struct) 849 if err := t.OwnerAddr.MarshalCBOR(w); err != nil { 850 return err 851 } 852 853 // t.WorkerAddr (address.Address) (struct) 854 if err := t.WorkerAddr.MarshalCBOR(w); err != nil { 855 return err 856 } 857 858 // t.ControlAddrs ([]address.Address) (slice) 859 if len(t.ControlAddrs) > cbg.MaxLength { 860 return xerrors.Errorf("Slice value in field t.ControlAddrs was too long") 861 } 862 863 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.ControlAddrs))); err != nil { 864 return err 865 } 866 for _, v := range t.ControlAddrs { 867 if err := v.MarshalCBOR(w); err != nil { 868 return err 869 } 870 } 871 872 // t.WindowPoStProofType (abi.RegisteredPoStProof) (int64) 873 if t.WindowPoStProofType >= 0 { 874 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.WindowPoStProofType)); err != nil { 875 return err 876 } 877 } else { 878 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.WindowPoStProofType-1)); err != nil { 879 return err 880 } 881 } 882 883 // t.PeerId ([]uint8) (slice) 884 if len(t.PeerId) > cbg.ByteArrayMaxLen { 885 return xerrors.Errorf("Byte array in field t.PeerId was too long") 886 } 887 888 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajByteString, uint64(len(t.PeerId))); err != nil { 889 return err 890 } 891 892 if _, err := w.Write(t.PeerId[:]); err != nil { 893 return err 894 } 895 896 // t.Multiaddrs ([][]uint8) (slice) 897 if len(t.Multiaddrs) > cbg.MaxLength { 898 return xerrors.Errorf("Slice value in field t.Multiaddrs was too long") 899 } 900 901 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Multiaddrs))); err != nil { 902 return err 903 } 904 for _, v := range t.Multiaddrs { 905 if len(v) > cbg.ByteArrayMaxLen { 906 return xerrors.Errorf("Byte array in field v was too long") 907 } 908 909 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajByteString, uint64(len(v))); err != nil { 910 return err 911 } 912 913 if _, err := w.Write(v[:]); err != nil { 914 return err 915 } 916 } 917 return nil 918 } 919 920 func (t *MinerConstructorParams) UnmarshalCBOR(r io.Reader) error { 921 *t = MinerConstructorParams{} 922 923 br := cbg.GetPeeker(r) 924 scratch := make([]byte, 8) 925 926 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 927 if err != nil { 928 return err 929 } 930 if maj != cbg.MajArray { 931 return fmt.Errorf("cbor input should be of type array") 932 } 933 934 if extra != 6 { 935 return fmt.Errorf("cbor input had wrong number of fields") 936 } 937 938 // t.OwnerAddr (address.Address) (struct) 939 940 { 941 942 if err := t.OwnerAddr.UnmarshalCBOR(br); err != nil { 943 return xerrors.Errorf("unmarshaling t.OwnerAddr: %w", err) 944 } 945 946 } 947 // t.WorkerAddr (address.Address) (struct) 948 949 { 950 951 if err := t.WorkerAddr.UnmarshalCBOR(br); err != nil { 952 return xerrors.Errorf("unmarshaling t.WorkerAddr: %w", err) 953 } 954 955 } 956 // t.ControlAddrs ([]address.Address) (slice) 957 958 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 959 if err != nil { 960 return err 961 } 962 963 if extra > cbg.MaxLength { 964 return fmt.Errorf("t.ControlAddrs: array too large (%d)", extra) 965 } 966 967 if maj != cbg.MajArray { 968 return fmt.Errorf("expected cbor array") 969 } 970 971 if extra > 0 { 972 t.ControlAddrs = make([]address.Address, extra) 973 } 974 975 for i := 0; i < int(extra); i++ { 976 977 var v address.Address 978 if err := v.UnmarshalCBOR(br); err != nil { 979 return err 980 } 981 982 t.ControlAddrs[i] = v 983 } 984 985 // t.WindowPoStProofType (abi.RegisteredPoStProof) (int64) 986 { 987 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 988 var extraI int64 989 if err != nil { 990 return err 991 } 992 switch maj { 993 case cbg.MajUnsignedInt: 994 extraI = int64(extra) 995 if extraI < 0 { 996 return fmt.Errorf("int64 positive overflow") 997 } 998 case cbg.MajNegativeInt: 999 extraI = int64(extra) 1000 if extraI < 0 { 1001 return fmt.Errorf("int64 negative oveflow") 1002 } 1003 extraI = -1 - extraI 1004 default: 1005 return fmt.Errorf("wrong type for int64 field: %d", maj) 1006 } 1007 1008 t.WindowPoStProofType = abi.RegisteredPoStProof(extraI) 1009 } 1010 // t.PeerId ([]uint8) (slice) 1011 1012 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 1013 if err != nil { 1014 return err 1015 } 1016 1017 if extra > cbg.ByteArrayMaxLen { 1018 return fmt.Errorf("t.PeerId: byte array too large (%d)", extra) 1019 } 1020 if maj != cbg.MajByteString { 1021 return fmt.Errorf("expected byte array") 1022 } 1023 1024 if extra > 0 { 1025 t.PeerId = make([]uint8, extra) 1026 } 1027 1028 if _, err := io.ReadFull(br, t.PeerId[:]); err != nil { 1029 return err 1030 } 1031 // t.Multiaddrs ([][]uint8) (slice) 1032 1033 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 1034 if err != nil { 1035 return err 1036 } 1037 1038 if extra > cbg.MaxLength { 1039 return fmt.Errorf("t.Multiaddrs: array too large (%d)", extra) 1040 } 1041 1042 if maj != cbg.MajArray { 1043 return fmt.Errorf("expected cbor array") 1044 } 1045 1046 if extra > 0 { 1047 t.Multiaddrs = make([][]uint8, extra) 1048 } 1049 1050 for i := 0; i < int(extra); i++ { 1051 { 1052 var maj byte 1053 var extra uint64 1054 var err error 1055 1056 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 1057 if err != nil { 1058 return err 1059 } 1060 1061 if extra > cbg.ByteArrayMaxLen { 1062 return fmt.Errorf("t.Multiaddrs[i]: byte array too large (%d)", extra) 1063 } 1064 if maj != cbg.MajByteString { 1065 return fmt.Errorf("expected byte array") 1066 } 1067 1068 if extra > 0 { 1069 t.Multiaddrs[i] = make([]uint8, extra) 1070 } 1071 1072 if _, err := io.ReadFull(br, t.Multiaddrs[i][:]); err != nil { 1073 return err 1074 } 1075 } 1076 } 1077 1078 return nil 1079 }