github.com/filecoin-project/specs-actors/v4@v4.0.2/actors/builtin/miner/cbor_gen.go (about) 1 // Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. 2 3 package miner 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 proof "github.com/filecoin-project/specs-actors/actors/runtime/proof" 12 cid "github.com/ipfs/go-cid" 13 cbg "github.com/whyrusleeping/cbor-gen" 14 xerrors "golang.org/x/xerrors" 15 ) 16 17 var _ = xerrors.Errorf 18 19 var lengthBufState = []byte{143} 20 21 func (t *State) MarshalCBOR(w io.Writer) error { 22 if t == nil { 23 _, err := w.Write(cbg.CborNull) 24 return err 25 } 26 if _, err := w.Write(lengthBufState); err != nil { 27 return err 28 } 29 30 scratch := make([]byte, 9) 31 32 // t.Info (cid.Cid) (struct) 33 34 if err := cbg.WriteCidBuf(scratch, w, t.Info); err != nil { 35 return xerrors.Errorf("failed to write cid field t.Info: %w", err) 36 } 37 38 // t.PreCommitDeposits (big.Int) (struct) 39 if err := t.PreCommitDeposits.MarshalCBOR(w); err != nil { 40 return err 41 } 42 43 // t.LockedFunds (big.Int) (struct) 44 if err := t.LockedFunds.MarshalCBOR(w); err != nil { 45 return err 46 } 47 48 // t.VestingFunds (cid.Cid) (struct) 49 50 if err := cbg.WriteCidBuf(scratch, w, t.VestingFunds); err != nil { 51 return xerrors.Errorf("failed to write cid field t.VestingFunds: %w", err) 52 } 53 54 // t.FeeDebt (big.Int) (struct) 55 if err := t.FeeDebt.MarshalCBOR(w); err != nil { 56 return err 57 } 58 59 // t.InitialPledge (big.Int) (struct) 60 if err := t.InitialPledge.MarshalCBOR(w); err != nil { 61 return err 62 } 63 64 // t.PreCommittedSectors (cid.Cid) (struct) 65 66 if err := cbg.WriteCidBuf(scratch, w, t.PreCommittedSectors); err != nil { 67 return xerrors.Errorf("failed to write cid field t.PreCommittedSectors: %w", err) 68 } 69 70 // t.PreCommittedSectorsExpiry (cid.Cid) (struct) 71 72 if err := cbg.WriteCidBuf(scratch, w, t.PreCommittedSectorsExpiry); err != nil { 73 return xerrors.Errorf("failed to write cid field t.PreCommittedSectorsExpiry: %w", err) 74 } 75 76 // t.AllocatedSectors (cid.Cid) (struct) 77 78 if err := cbg.WriteCidBuf(scratch, w, t.AllocatedSectors); err != nil { 79 return xerrors.Errorf("failed to write cid field t.AllocatedSectors: %w", err) 80 } 81 82 // t.Sectors (cid.Cid) (struct) 83 84 if err := cbg.WriteCidBuf(scratch, w, t.Sectors); err != nil { 85 return xerrors.Errorf("failed to write cid field t.Sectors: %w", err) 86 } 87 88 // t.ProvingPeriodStart (abi.ChainEpoch) (int64) 89 if t.ProvingPeriodStart >= 0 { 90 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.ProvingPeriodStart)); err != nil { 91 return err 92 } 93 } else { 94 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.ProvingPeriodStart-1)); err != nil { 95 return err 96 } 97 } 98 99 // t.CurrentDeadline (uint64) (uint64) 100 101 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.CurrentDeadline)); err != nil { 102 return err 103 } 104 105 // t.Deadlines (cid.Cid) (struct) 106 107 if err := cbg.WriteCidBuf(scratch, w, t.Deadlines); err != nil { 108 return xerrors.Errorf("failed to write cid field t.Deadlines: %w", err) 109 } 110 111 // t.EarlyTerminations (bitfield.BitField) (struct) 112 if err := t.EarlyTerminations.MarshalCBOR(w); err != nil { 113 return err 114 } 115 116 // t.DeadlineCronActive (bool) (bool) 117 if err := cbg.WriteBool(w, t.DeadlineCronActive); err != nil { 118 return err 119 } 120 return nil 121 } 122 123 func (t *State) UnmarshalCBOR(r io.Reader) error { 124 *t = State{} 125 126 br := cbg.GetPeeker(r) 127 scratch := make([]byte, 8) 128 129 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 130 if err != nil { 131 return err 132 } 133 if maj != cbg.MajArray { 134 return fmt.Errorf("cbor input should be of type array") 135 } 136 137 if extra != 15 { 138 return fmt.Errorf("cbor input had wrong number of fields") 139 } 140 141 // t.Info (cid.Cid) (struct) 142 143 { 144 145 c, err := cbg.ReadCid(br) 146 if err != nil { 147 return xerrors.Errorf("failed to read cid field t.Info: %w", err) 148 } 149 150 t.Info = c 151 152 } 153 // t.PreCommitDeposits (big.Int) (struct) 154 155 { 156 157 if err := t.PreCommitDeposits.UnmarshalCBOR(br); err != nil { 158 return xerrors.Errorf("unmarshaling t.PreCommitDeposits: %w", err) 159 } 160 161 } 162 // t.LockedFunds (big.Int) (struct) 163 164 { 165 166 if err := t.LockedFunds.UnmarshalCBOR(br); err != nil { 167 return xerrors.Errorf("unmarshaling t.LockedFunds: %w", err) 168 } 169 170 } 171 // t.VestingFunds (cid.Cid) (struct) 172 173 { 174 175 c, err := cbg.ReadCid(br) 176 if err != nil { 177 return xerrors.Errorf("failed to read cid field t.VestingFunds: %w", err) 178 } 179 180 t.VestingFunds = c 181 182 } 183 // t.FeeDebt (big.Int) (struct) 184 185 { 186 187 if err := t.FeeDebt.UnmarshalCBOR(br); err != nil { 188 return xerrors.Errorf("unmarshaling t.FeeDebt: %w", err) 189 } 190 191 } 192 // t.InitialPledge (big.Int) (struct) 193 194 { 195 196 if err := t.InitialPledge.UnmarshalCBOR(br); err != nil { 197 return xerrors.Errorf("unmarshaling t.InitialPledge: %w", err) 198 } 199 200 } 201 // t.PreCommittedSectors (cid.Cid) (struct) 202 203 { 204 205 c, err := cbg.ReadCid(br) 206 if err != nil { 207 return xerrors.Errorf("failed to read cid field t.PreCommittedSectors: %w", err) 208 } 209 210 t.PreCommittedSectors = c 211 212 } 213 // t.PreCommittedSectorsExpiry (cid.Cid) (struct) 214 215 { 216 217 c, err := cbg.ReadCid(br) 218 if err != nil { 219 return xerrors.Errorf("failed to read cid field t.PreCommittedSectorsExpiry: %w", err) 220 } 221 222 t.PreCommittedSectorsExpiry = c 223 224 } 225 // t.AllocatedSectors (cid.Cid) (struct) 226 227 { 228 229 c, err := cbg.ReadCid(br) 230 if err != nil { 231 return xerrors.Errorf("failed to read cid field t.AllocatedSectors: %w", err) 232 } 233 234 t.AllocatedSectors = c 235 236 } 237 // t.Sectors (cid.Cid) (struct) 238 239 { 240 241 c, err := cbg.ReadCid(br) 242 if err != nil { 243 return xerrors.Errorf("failed to read cid field t.Sectors: %w", err) 244 } 245 246 t.Sectors = c 247 248 } 249 // t.ProvingPeriodStart (abi.ChainEpoch) (int64) 250 { 251 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 252 var extraI int64 253 if err != nil { 254 return err 255 } 256 switch maj { 257 case cbg.MajUnsignedInt: 258 extraI = int64(extra) 259 if extraI < 0 { 260 return fmt.Errorf("int64 positive overflow") 261 } 262 case cbg.MajNegativeInt: 263 extraI = int64(extra) 264 if extraI < 0 { 265 return fmt.Errorf("int64 negative oveflow") 266 } 267 extraI = -1 - extraI 268 default: 269 return fmt.Errorf("wrong type for int64 field: %d", maj) 270 } 271 272 t.ProvingPeriodStart = abi.ChainEpoch(extraI) 273 } 274 // t.CurrentDeadline (uint64) (uint64) 275 276 { 277 278 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 279 if err != nil { 280 return err 281 } 282 if maj != cbg.MajUnsignedInt { 283 return fmt.Errorf("wrong type for uint64 field") 284 } 285 t.CurrentDeadline = uint64(extra) 286 287 } 288 // t.Deadlines (cid.Cid) (struct) 289 290 { 291 292 c, err := cbg.ReadCid(br) 293 if err != nil { 294 return xerrors.Errorf("failed to read cid field t.Deadlines: %w", err) 295 } 296 297 t.Deadlines = c 298 299 } 300 // t.EarlyTerminations (bitfield.BitField) (struct) 301 302 { 303 304 if err := t.EarlyTerminations.UnmarshalCBOR(br); err != nil { 305 return xerrors.Errorf("unmarshaling t.EarlyTerminations: %w", err) 306 } 307 308 } 309 // t.DeadlineCronActive (bool) (bool) 310 311 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 312 if err != nil { 313 return err 314 } 315 if maj != cbg.MajOther { 316 return fmt.Errorf("booleans must be major type 7") 317 } 318 switch extra { 319 case 20: 320 t.DeadlineCronActive = false 321 case 21: 322 t.DeadlineCronActive = true 323 default: 324 return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) 325 } 326 return nil 327 } 328 329 var lengthBufMinerInfo = []byte{139} 330 331 func (t *MinerInfo) MarshalCBOR(w io.Writer) error { 332 if t == nil { 333 _, err := w.Write(cbg.CborNull) 334 return err 335 } 336 if _, err := w.Write(lengthBufMinerInfo); err != nil { 337 return err 338 } 339 340 scratch := make([]byte, 9) 341 342 // t.Owner (address.Address) (struct) 343 if err := t.Owner.MarshalCBOR(w); err != nil { 344 return err 345 } 346 347 // t.Worker (address.Address) (struct) 348 if err := t.Worker.MarshalCBOR(w); err != nil { 349 return err 350 } 351 352 // t.ControlAddresses ([]address.Address) (slice) 353 if len(t.ControlAddresses) > cbg.MaxLength { 354 return xerrors.Errorf("Slice value in field t.ControlAddresses was too long") 355 } 356 357 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.ControlAddresses))); err != nil { 358 return err 359 } 360 for _, v := range t.ControlAddresses { 361 if err := v.MarshalCBOR(w); err != nil { 362 return err 363 } 364 } 365 366 // t.PendingWorkerKey (miner.WorkerKeyChange) (struct) 367 if err := t.PendingWorkerKey.MarshalCBOR(w); err != nil { 368 return err 369 } 370 371 // t.PeerId ([]uint8) (slice) 372 if len(t.PeerId) > cbg.ByteArrayMaxLen { 373 return xerrors.Errorf("Byte array in field t.PeerId was too long") 374 } 375 376 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajByteString, uint64(len(t.PeerId))); err != nil { 377 return err 378 } 379 380 if _, err := w.Write(t.PeerId[:]); err != nil { 381 return err 382 } 383 384 // t.Multiaddrs ([][]uint8) (slice) 385 if len(t.Multiaddrs) > cbg.MaxLength { 386 return xerrors.Errorf("Slice value in field t.Multiaddrs was too long") 387 } 388 389 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Multiaddrs))); err != nil { 390 return err 391 } 392 for _, v := range t.Multiaddrs { 393 if len(v) > cbg.ByteArrayMaxLen { 394 return xerrors.Errorf("Byte array in field v was too long") 395 } 396 397 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajByteString, uint64(len(v))); err != nil { 398 return err 399 } 400 401 if _, err := w.Write(v[:]); err != nil { 402 return err 403 } 404 } 405 406 // t.WindowPoStProofType (abi.RegisteredPoStProof) (int64) 407 if t.WindowPoStProofType >= 0 { 408 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.WindowPoStProofType)); err != nil { 409 return err 410 } 411 } else { 412 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.WindowPoStProofType-1)); err != nil { 413 return err 414 } 415 } 416 417 // t.SectorSize (abi.SectorSize) (uint64) 418 419 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.SectorSize)); err != nil { 420 return err 421 } 422 423 // t.WindowPoStPartitionSectors (uint64) (uint64) 424 425 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.WindowPoStPartitionSectors)); err != nil { 426 return err 427 } 428 429 // t.ConsensusFaultElapsed (abi.ChainEpoch) (int64) 430 if t.ConsensusFaultElapsed >= 0 { 431 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.ConsensusFaultElapsed)); err != nil { 432 return err 433 } 434 } else { 435 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.ConsensusFaultElapsed-1)); err != nil { 436 return err 437 } 438 } 439 440 // t.PendingOwnerAddress (address.Address) (struct) 441 if err := t.PendingOwnerAddress.MarshalCBOR(w); err != nil { 442 return err 443 } 444 return nil 445 } 446 447 func (t *MinerInfo) UnmarshalCBOR(r io.Reader) error { 448 *t = MinerInfo{} 449 450 br := cbg.GetPeeker(r) 451 scratch := make([]byte, 8) 452 453 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 454 if err != nil { 455 return err 456 } 457 if maj != cbg.MajArray { 458 return fmt.Errorf("cbor input should be of type array") 459 } 460 461 if extra != 11 { 462 return fmt.Errorf("cbor input had wrong number of fields") 463 } 464 465 // t.Owner (address.Address) (struct) 466 467 { 468 469 if err := t.Owner.UnmarshalCBOR(br); err != nil { 470 return xerrors.Errorf("unmarshaling t.Owner: %w", err) 471 } 472 473 } 474 // t.Worker (address.Address) (struct) 475 476 { 477 478 if err := t.Worker.UnmarshalCBOR(br); err != nil { 479 return xerrors.Errorf("unmarshaling t.Worker: %w", err) 480 } 481 482 } 483 // t.ControlAddresses ([]address.Address) (slice) 484 485 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 486 if err != nil { 487 return err 488 } 489 490 if extra > cbg.MaxLength { 491 return fmt.Errorf("t.ControlAddresses: array too large (%d)", extra) 492 } 493 494 if maj != cbg.MajArray { 495 return fmt.Errorf("expected cbor array") 496 } 497 498 if extra > 0 { 499 t.ControlAddresses = make([]address.Address, extra) 500 } 501 502 for i := 0; i < int(extra); i++ { 503 504 var v address.Address 505 if err := v.UnmarshalCBOR(br); err != nil { 506 return err 507 } 508 509 t.ControlAddresses[i] = v 510 } 511 512 // t.PendingWorkerKey (miner.WorkerKeyChange) (struct) 513 514 { 515 516 b, err := br.ReadByte() 517 if err != nil { 518 return err 519 } 520 if b != cbg.CborNull[0] { 521 if err := br.UnreadByte(); err != nil { 522 return err 523 } 524 t.PendingWorkerKey = new(WorkerKeyChange) 525 if err := t.PendingWorkerKey.UnmarshalCBOR(br); err != nil { 526 return xerrors.Errorf("unmarshaling t.PendingWorkerKey pointer: %w", err) 527 } 528 } 529 530 } 531 // t.PeerId ([]uint8) (slice) 532 533 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 534 if err != nil { 535 return err 536 } 537 538 if extra > cbg.ByteArrayMaxLen { 539 return fmt.Errorf("t.PeerId: byte array too large (%d)", extra) 540 } 541 if maj != cbg.MajByteString { 542 return fmt.Errorf("expected byte array") 543 } 544 545 if extra > 0 { 546 t.PeerId = make([]uint8, extra) 547 } 548 549 if _, err := io.ReadFull(br, t.PeerId[:]); err != nil { 550 return err 551 } 552 // t.Multiaddrs ([][]uint8) (slice) 553 554 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 555 if err != nil { 556 return err 557 } 558 559 if extra > cbg.MaxLength { 560 return fmt.Errorf("t.Multiaddrs: array too large (%d)", extra) 561 } 562 563 if maj != cbg.MajArray { 564 return fmt.Errorf("expected cbor array") 565 } 566 567 if extra > 0 { 568 t.Multiaddrs = make([][]uint8, extra) 569 } 570 571 for i := 0; i < int(extra); i++ { 572 { 573 var maj byte 574 var extra uint64 575 var err error 576 577 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 578 if err != nil { 579 return err 580 } 581 582 if extra > cbg.ByteArrayMaxLen { 583 return fmt.Errorf("t.Multiaddrs[i]: byte array too large (%d)", extra) 584 } 585 if maj != cbg.MajByteString { 586 return fmt.Errorf("expected byte array") 587 } 588 589 if extra > 0 { 590 t.Multiaddrs[i] = make([]uint8, extra) 591 } 592 593 if _, err := io.ReadFull(br, t.Multiaddrs[i][:]); err != nil { 594 return err 595 } 596 } 597 } 598 599 // t.WindowPoStProofType (abi.RegisteredPoStProof) (int64) 600 { 601 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 602 var extraI int64 603 if err != nil { 604 return err 605 } 606 switch maj { 607 case cbg.MajUnsignedInt: 608 extraI = int64(extra) 609 if extraI < 0 { 610 return fmt.Errorf("int64 positive overflow") 611 } 612 case cbg.MajNegativeInt: 613 extraI = int64(extra) 614 if extraI < 0 { 615 return fmt.Errorf("int64 negative oveflow") 616 } 617 extraI = -1 - extraI 618 default: 619 return fmt.Errorf("wrong type for int64 field: %d", maj) 620 } 621 622 t.WindowPoStProofType = abi.RegisteredPoStProof(extraI) 623 } 624 // t.SectorSize (abi.SectorSize) (uint64) 625 626 { 627 628 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 629 if err != nil { 630 return err 631 } 632 if maj != cbg.MajUnsignedInt { 633 return fmt.Errorf("wrong type for uint64 field") 634 } 635 t.SectorSize = abi.SectorSize(extra) 636 637 } 638 // t.WindowPoStPartitionSectors (uint64) (uint64) 639 640 { 641 642 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 643 if err != nil { 644 return err 645 } 646 if maj != cbg.MajUnsignedInt { 647 return fmt.Errorf("wrong type for uint64 field") 648 } 649 t.WindowPoStPartitionSectors = uint64(extra) 650 651 } 652 // t.ConsensusFaultElapsed (abi.ChainEpoch) (int64) 653 { 654 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 655 var extraI int64 656 if err != nil { 657 return err 658 } 659 switch maj { 660 case cbg.MajUnsignedInt: 661 extraI = int64(extra) 662 if extraI < 0 { 663 return fmt.Errorf("int64 positive overflow") 664 } 665 case cbg.MajNegativeInt: 666 extraI = int64(extra) 667 if extraI < 0 { 668 return fmt.Errorf("int64 negative oveflow") 669 } 670 extraI = -1 - extraI 671 default: 672 return fmt.Errorf("wrong type for int64 field: %d", maj) 673 } 674 675 t.ConsensusFaultElapsed = abi.ChainEpoch(extraI) 676 } 677 // t.PendingOwnerAddress (address.Address) (struct) 678 679 { 680 681 b, err := br.ReadByte() 682 if err != nil { 683 return err 684 } 685 if b != cbg.CborNull[0] { 686 if err := br.UnreadByte(); err != nil { 687 return err 688 } 689 t.PendingOwnerAddress = new(address.Address) 690 if err := t.PendingOwnerAddress.UnmarshalCBOR(br); err != nil { 691 return xerrors.Errorf("unmarshaling t.PendingOwnerAddress pointer: %w", err) 692 } 693 } 694 695 } 696 return nil 697 } 698 699 var lengthBufDeadlines = []byte{129} 700 701 func (t *Deadlines) MarshalCBOR(w io.Writer) error { 702 if t == nil { 703 _, err := w.Write(cbg.CborNull) 704 return err 705 } 706 if _, err := w.Write(lengthBufDeadlines); err != nil { 707 return err 708 } 709 710 scratch := make([]byte, 9) 711 712 // t.Due ([48]cid.Cid) (array) 713 if len(t.Due) > cbg.MaxLength { 714 return xerrors.Errorf("Slice value in field t.Due was too long") 715 } 716 717 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Due))); err != nil { 718 return err 719 } 720 for _, v := range t.Due { 721 if err := cbg.WriteCidBuf(scratch, w, v); err != nil { 722 return xerrors.Errorf("failed writing cid field t.Due: %w", err) 723 } 724 } 725 return nil 726 } 727 728 func (t *Deadlines) UnmarshalCBOR(r io.Reader) error { 729 *t = Deadlines{} 730 731 br := cbg.GetPeeker(r) 732 scratch := make([]byte, 8) 733 734 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 735 if err != nil { 736 return err 737 } 738 if maj != cbg.MajArray { 739 return fmt.Errorf("cbor input should be of type array") 740 } 741 742 if extra != 1 { 743 return fmt.Errorf("cbor input had wrong number of fields") 744 } 745 746 // t.Due ([48]cid.Cid) (array) 747 748 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 749 if err != nil { 750 return err 751 } 752 753 if extra > cbg.MaxLength { 754 return fmt.Errorf("t.Due: array too large (%d)", extra) 755 } 756 757 if maj != cbg.MajArray { 758 return fmt.Errorf("expected cbor array") 759 } 760 761 if extra != 48 { 762 return fmt.Errorf("expected array to have 48 elements") 763 } 764 765 t.Due = [48]cid.Cid{} 766 767 for i := 0; i < int(extra); i++ { 768 769 c, err := cbg.ReadCid(br) 770 if err != nil { 771 return xerrors.Errorf("reading cid field t.Due failed: %w", err) 772 } 773 t.Due[i] = c 774 } 775 776 return nil 777 } 778 779 var lengthBufDeadline = []byte{138} 780 781 func (t *Deadline) MarshalCBOR(w io.Writer) error { 782 if t == nil { 783 _, err := w.Write(cbg.CborNull) 784 return err 785 } 786 if _, err := w.Write(lengthBufDeadline); err != nil { 787 return err 788 } 789 790 scratch := make([]byte, 9) 791 792 // t.Partitions (cid.Cid) (struct) 793 794 if err := cbg.WriteCidBuf(scratch, w, t.Partitions); err != nil { 795 return xerrors.Errorf("failed to write cid field t.Partitions: %w", err) 796 } 797 798 // t.ExpirationsEpochs (cid.Cid) (struct) 799 800 if err := cbg.WriteCidBuf(scratch, w, t.ExpirationsEpochs); err != nil { 801 return xerrors.Errorf("failed to write cid field t.ExpirationsEpochs: %w", err) 802 } 803 804 // t.PartitionsPoSted (bitfield.BitField) (struct) 805 if err := t.PartitionsPoSted.MarshalCBOR(w); err != nil { 806 return err 807 } 808 809 // t.EarlyTerminations (bitfield.BitField) (struct) 810 if err := t.EarlyTerminations.MarshalCBOR(w); err != nil { 811 return err 812 } 813 814 // t.LiveSectors (uint64) (uint64) 815 816 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.LiveSectors)); err != nil { 817 return err 818 } 819 820 // t.TotalSectors (uint64) (uint64) 821 822 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.TotalSectors)); err != nil { 823 return err 824 } 825 826 // t.FaultyPower (miner.PowerPair) (struct) 827 if err := t.FaultyPower.MarshalCBOR(w); err != nil { 828 return err 829 } 830 831 // t.OptimisticPoStSubmissions (cid.Cid) (struct) 832 833 if err := cbg.WriteCidBuf(scratch, w, t.OptimisticPoStSubmissions); err != nil { 834 return xerrors.Errorf("failed to write cid field t.OptimisticPoStSubmissions: %w", err) 835 } 836 837 // t.PartitionsSnapshot (cid.Cid) (struct) 838 839 if err := cbg.WriteCidBuf(scratch, w, t.PartitionsSnapshot); err != nil { 840 return xerrors.Errorf("failed to write cid field t.PartitionsSnapshot: %w", err) 841 } 842 843 // t.OptimisticPoStSubmissionsSnapshot (cid.Cid) (struct) 844 845 if err := cbg.WriteCidBuf(scratch, w, t.OptimisticPoStSubmissionsSnapshot); err != nil { 846 return xerrors.Errorf("failed to write cid field t.OptimisticPoStSubmissionsSnapshot: %w", err) 847 } 848 849 return nil 850 } 851 852 func (t *Deadline) UnmarshalCBOR(r io.Reader) error { 853 *t = Deadline{} 854 855 br := cbg.GetPeeker(r) 856 scratch := make([]byte, 8) 857 858 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 859 if err != nil { 860 return err 861 } 862 if maj != cbg.MajArray { 863 return fmt.Errorf("cbor input should be of type array") 864 } 865 866 if extra != 10 { 867 return fmt.Errorf("cbor input had wrong number of fields") 868 } 869 870 // t.Partitions (cid.Cid) (struct) 871 872 { 873 874 c, err := cbg.ReadCid(br) 875 if err != nil { 876 return xerrors.Errorf("failed to read cid field t.Partitions: %w", err) 877 } 878 879 t.Partitions = c 880 881 } 882 // t.ExpirationsEpochs (cid.Cid) (struct) 883 884 { 885 886 c, err := cbg.ReadCid(br) 887 if err != nil { 888 return xerrors.Errorf("failed to read cid field t.ExpirationsEpochs: %w", err) 889 } 890 891 t.ExpirationsEpochs = c 892 893 } 894 // t.PartitionsPoSted (bitfield.BitField) (struct) 895 896 { 897 898 if err := t.PartitionsPoSted.UnmarshalCBOR(br); err != nil { 899 return xerrors.Errorf("unmarshaling t.PartitionsPoSted: %w", err) 900 } 901 902 } 903 // t.EarlyTerminations (bitfield.BitField) (struct) 904 905 { 906 907 if err := t.EarlyTerminations.UnmarshalCBOR(br); err != nil { 908 return xerrors.Errorf("unmarshaling t.EarlyTerminations: %w", err) 909 } 910 911 } 912 // t.LiveSectors (uint64) (uint64) 913 914 { 915 916 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 917 if err != nil { 918 return err 919 } 920 if maj != cbg.MajUnsignedInt { 921 return fmt.Errorf("wrong type for uint64 field") 922 } 923 t.LiveSectors = uint64(extra) 924 925 } 926 // t.TotalSectors (uint64) (uint64) 927 928 { 929 930 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 931 if err != nil { 932 return err 933 } 934 if maj != cbg.MajUnsignedInt { 935 return fmt.Errorf("wrong type for uint64 field") 936 } 937 t.TotalSectors = uint64(extra) 938 939 } 940 // t.FaultyPower (miner.PowerPair) (struct) 941 942 { 943 944 if err := t.FaultyPower.UnmarshalCBOR(br); err != nil { 945 return xerrors.Errorf("unmarshaling t.FaultyPower: %w", err) 946 } 947 948 } 949 // t.OptimisticPoStSubmissions (cid.Cid) (struct) 950 951 { 952 953 c, err := cbg.ReadCid(br) 954 if err != nil { 955 return xerrors.Errorf("failed to read cid field t.OptimisticPoStSubmissions: %w", err) 956 } 957 958 t.OptimisticPoStSubmissions = c 959 960 } 961 // t.PartitionsSnapshot (cid.Cid) (struct) 962 963 { 964 965 c, err := cbg.ReadCid(br) 966 if err != nil { 967 return xerrors.Errorf("failed to read cid field t.PartitionsSnapshot: %w", err) 968 } 969 970 t.PartitionsSnapshot = c 971 972 } 973 // t.OptimisticPoStSubmissionsSnapshot (cid.Cid) (struct) 974 975 { 976 977 c, err := cbg.ReadCid(br) 978 if err != nil { 979 return xerrors.Errorf("failed to read cid field t.OptimisticPoStSubmissionsSnapshot: %w", err) 980 } 981 982 t.OptimisticPoStSubmissionsSnapshot = c 983 984 } 985 return nil 986 } 987 988 var lengthBufPartition = []byte{139} 989 990 func (t *Partition) MarshalCBOR(w io.Writer) error { 991 if t == nil { 992 _, err := w.Write(cbg.CborNull) 993 return err 994 } 995 if _, err := w.Write(lengthBufPartition); err != nil { 996 return err 997 } 998 999 scratch := make([]byte, 9) 1000 1001 // t.Sectors (bitfield.BitField) (struct) 1002 if err := t.Sectors.MarshalCBOR(w); err != nil { 1003 return err 1004 } 1005 1006 // t.Unproven (bitfield.BitField) (struct) 1007 if err := t.Unproven.MarshalCBOR(w); err != nil { 1008 return err 1009 } 1010 1011 // t.Faults (bitfield.BitField) (struct) 1012 if err := t.Faults.MarshalCBOR(w); err != nil { 1013 return err 1014 } 1015 1016 // t.Recoveries (bitfield.BitField) (struct) 1017 if err := t.Recoveries.MarshalCBOR(w); err != nil { 1018 return err 1019 } 1020 1021 // t.Terminated (bitfield.BitField) (struct) 1022 if err := t.Terminated.MarshalCBOR(w); err != nil { 1023 return err 1024 } 1025 1026 // t.ExpirationsEpochs (cid.Cid) (struct) 1027 1028 if err := cbg.WriteCidBuf(scratch, w, t.ExpirationsEpochs); err != nil { 1029 return xerrors.Errorf("failed to write cid field t.ExpirationsEpochs: %w", err) 1030 } 1031 1032 // t.EarlyTerminated (cid.Cid) (struct) 1033 1034 if err := cbg.WriteCidBuf(scratch, w, t.EarlyTerminated); err != nil { 1035 return xerrors.Errorf("failed to write cid field t.EarlyTerminated: %w", err) 1036 } 1037 1038 // t.LivePower (miner.PowerPair) (struct) 1039 if err := t.LivePower.MarshalCBOR(w); err != nil { 1040 return err 1041 } 1042 1043 // t.UnprovenPower (miner.PowerPair) (struct) 1044 if err := t.UnprovenPower.MarshalCBOR(w); err != nil { 1045 return err 1046 } 1047 1048 // t.FaultyPower (miner.PowerPair) (struct) 1049 if err := t.FaultyPower.MarshalCBOR(w); err != nil { 1050 return err 1051 } 1052 1053 // t.RecoveringPower (miner.PowerPair) (struct) 1054 if err := t.RecoveringPower.MarshalCBOR(w); err != nil { 1055 return err 1056 } 1057 return nil 1058 } 1059 1060 func (t *Partition) UnmarshalCBOR(r io.Reader) error { 1061 *t = Partition{} 1062 1063 br := cbg.GetPeeker(r) 1064 scratch := make([]byte, 8) 1065 1066 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 1067 if err != nil { 1068 return err 1069 } 1070 if maj != cbg.MajArray { 1071 return fmt.Errorf("cbor input should be of type array") 1072 } 1073 1074 if extra != 11 { 1075 return fmt.Errorf("cbor input had wrong number of fields") 1076 } 1077 1078 // t.Sectors (bitfield.BitField) (struct) 1079 1080 { 1081 1082 if err := t.Sectors.UnmarshalCBOR(br); err != nil { 1083 return xerrors.Errorf("unmarshaling t.Sectors: %w", err) 1084 } 1085 1086 } 1087 // t.Unproven (bitfield.BitField) (struct) 1088 1089 { 1090 1091 if err := t.Unproven.UnmarshalCBOR(br); err != nil { 1092 return xerrors.Errorf("unmarshaling t.Unproven: %w", err) 1093 } 1094 1095 } 1096 // t.Faults (bitfield.BitField) (struct) 1097 1098 { 1099 1100 if err := t.Faults.UnmarshalCBOR(br); err != nil { 1101 return xerrors.Errorf("unmarshaling t.Faults: %w", err) 1102 } 1103 1104 } 1105 // t.Recoveries (bitfield.BitField) (struct) 1106 1107 { 1108 1109 if err := t.Recoveries.UnmarshalCBOR(br); err != nil { 1110 return xerrors.Errorf("unmarshaling t.Recoveries: %w", err) 1111 } 1112 1113 } 1114 // t.Terminated (bitfield.BitField) (struct) 1115 1116 { 1117 1118 if err := t.Terminated.UnmarshalCBOR(br); err != nil { 1119 return xerrors.Errorf("unmarshaling t.Terminated: %w", err) 1120 } 1121 1122 } 1123 // t.ExpirationsEpochs (cid.Cid) (struct) 1124 1125 { 1126 1127 c, err := cbg.ReadCid(br) 1128 if err != nil { 1129 return xerrors.Errorf("failed to read cid field t.ExpirationsEpochs: %w", err) 1130 } 1131 1132 t.ExpirationsEpochs = c 1133 1134 } 1135 // t.EarlyTerminated (cid.Cid) (struct) 1136 1137 { 1138 1139 c, err := cbg.ReadCid(br) 1140 if err != nil { 1141 return xerrors.Errorf("failed to read cid field t.EarlyTerminated: %w", err) 1142 } 1143 1144 t.EarlyTerminated = c 1145 1146 } 1147 // t.LivePower (miner.PowerPair) (struct) 1148 1149 { 1150 1151 if err := t.LivePower.UnmarshalCBOR(br); err != nil { 1152 return xerrors.Errorf("unmarshaling t.LivePower: %w", err) 1153 } 1154 1155 } 1156 // t.UnprovenPower (miner.PowerPair) (struct) 1157 1158 { 1159 1160 if err := t.UnprovenPower.UnmarshalCBOR(br); err != nil { 1161 return xerrors.Errorf("unmarshaling t.UnprovenPower: %w", err) 1162 } 1163 1164 } 1165 // t.FaultyPower (miner.PowerPair) (struct) 1166 1167 { 1168 1169 if err := t.FaultyPower.UnmarshalCBOR(br); err != nil { 1170 return xerrors.Errorf("unmarshaling t.FaultyPower: %w", err) 1171 } 1172 1173 } 1174 // t.RecoveringPower (miner.PowerPair) (struct) 1175 1176 { 1177 1178 if err := t.RecoveringPower.UnmarshalCBOR(br); err != nil { 1179 return xerrors.Errorf("unmarshaling t.RecoveringPower: %w", err) 1180 } 1181 1182 } 1183 return nil 1184 } 1185 1186 var lengthBufExpirationSet = []byte{133} 1187 1188 func (t *ExpirationSet) MarshalCBOR(w io.Writer) error { 1189 if t == nil { 1190 _, err := w.Write(cbg.CborNull) 1191 return err 1192 } 1193 if _, err := w.Write(lengthBufExpirationSet); err != nil { 1194 return err 1195 } 1196 1197 // t.OnTimeSectors (bitfield.BitField) (struct) 1198 if err := t.OnTimeSectors.MarshalCBOR(w); err != nil { 1199 return err 1200 } 1201 1202 // t.EarlySectors (bitfield.BitField) (struct) 1203 if err := t.EarlySectors.MarshalCBOR(w); err != nil { 1204 return err 1205 } 1206 1207 // t.OnTimePledge (big.Int) (struct) 1208 if err := t.OnTimePledge.MarshalCBOR(w); err != nil { 1209 return err 1210 } 1211 1212 // t.ActivePower (miner.PowerPair) (struct) 1213 if err := t.ActivePower.MarshalCBOR(w); err != nil { 1214 return err 1215 } 1216 1217 // t.FaultyPower (miner.PowerPair) (struct) 1218 if err := t.FaultyPower.MarshalCBOR(w); err != nil { 1219 return err 1220 } 1221 return nil 1222 } 1223 1224 func (t *ExpirationSet) UnmarshalCBOR(r io.Reader) error { 1225 *t = ExpirationSet{} 1226 1227 br := cbg.GetPeeker(r) 1228 scratch := make([]byte, 8) 1229 1230 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 1231 if err != nil { 1232 return err 1233 } 1234 if maj != cbg.MajArray { 1235 return fmt.Errorf("cbor input should be of type array") 1236 } 1237 1238 if extra != 5 { 1239 return fmt.Errorf("cbor input had wrong number of fields") 1240 } 1241 1242 // t.OnTimeSectors (bitfield.BitField) (struct) 1243 1244 { 1245 1246 if err := t.OnTimeSectors.UnmarshalCBOR(br); err != nil { 1247 return xerrors.Errorf("unmarshaling t.OnTimeSectors: %w", err) 1248 } 1249 1250 } 1251 // t.EarlySectors (bitfield.BitField) (struct) 1252 1253 { 1254 1255 if err := t.EarlySectors.UnmarshalCBOR(br); err != nil { 1256 return xerrors.Errorf("unmarshaling t.EarlySectors: %w", err) 1257 } 1258 1259 } 1260 // t.OnTimePledge (big.Int) (struct) 1261 1262 { 1263 1264 if err := t.OnTimePledge.UnmarshalCBOR(br); err != nil { 1265 return xerrors.Errorf("unmarshaling t.OnTimePledge: %w", err) 1266 } 1267 1268 } 1269 // t.ActivePower (miner.PowerPair) (struct) 1270 1271 { 1272 1273 if err := t.ActivePower.UnmarshalCBOR(br); err != nil { 1274 return xerrors.Errorf("unmarshaling t.ActivePower: %w", err) 1275 } 1276 1277 } 1278 // t.FaultyPower (miner.PowerPair) (struct) 1279 1280 { 1281 1282 if err := t.FaultyPower.UnmarshalCBOR(br); err != nil { 1283 return xerrors.Errorf("unmarshaling t.FaultyPower: %w", err) 1284 } 1285 1286 } 1287 return nil 1288 } 1289 1290 var lengthBufPowerPair = []byte{130} 1291 1292 func (t *PowerPair) MarshalCBOR(w io.Writer) error { 1293 if t == nil { 1294 _, err := w.Write(cbg.CborNull) 1295 return err 1296 } 1297 if _, err := w.Write(lengthBufPowerPair); err != nil { 1298 return err 1299 } 1300 1301 // t.Raw (big.Int) (struct) 1302 if err := t.Raw.MarshalCBOR(w); err != nil { 1303 return err 1304 } 1305 1306 // t.QA (big.Int) (struct) 1307 if err := t.QA.MarshalCBOR(w); err != nil { 1308 return err 1309 } 1310 return nil 1311 } 1312 1313 func (t *PowerPair) UnmarshalCBOR(r io.Reader) error { 1314 *t = PowerPair{} 1315 1316 br := cbg.GetPeeker(r) 1317 scratch := make([]byte, 8) 1318 1319 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 1320 if err != nil { 1321 return err 1322 } 1323 if maj != cbg.MajArray { 1324 return fmt.Errorf("cbor input should be of type array") 1325 } 1326 1327 if extra != 2 { 1328 return fmt.Errorf("cbor input had wrong number of fields") 1329 } 1330 1331 // t.Raw (big.Int) (struct) 1332 1333 { 1334 1335 if err := t.Raw.UnmarshalCBOR(br); err != nil { 1336 return xerrors.Errorf("unmarshaling t.Raw: %w", err) 1337 } 1338 1339 } 1340 // t.QA (big.Int) (struct) 1341 1342 { 1343 1344 if err := t.QA.UnmarshalCBOR(br); err != nil { 1345 return xerrors.Errorf("unmarshaling t.QA: %w", err) 1346 } 1347 1348 } 1349 return nil 1350 } 1351 1352 var lengthBufSectorPreCommitOnChainInfo = []byte{133} 1353 1354 func (t *SectorPreCommitOnChainInfo) MarshalCBOR(w io.Writer) error { 1355 if t == nil { 1356 _, err := w.Write(cbg.CborNull) 1357 return err 1358 } 1359 if _, err := w.Write(lengthBufSectorPreCommitOnChainInfo); err != nil { 1360 return err 1361 } 1362 1363 scratch := make([]byte, 9) 1364 1365 // t.Info (miner.SectorPreCommitInfo) (struct) 1366 if err := t.Info.MarshalCBOR(w); err != nil { 1367 return err 1368 } 1369 1370 // t.PreCommitDeposit (big.Int) (struct) 1371 if err := t.PreCommitDeposit.MarshalCBOR(w); err != nil { 1372 return err 1373 } 1374 1375 // t.PreCommitEpoch (abi.ChainEpoch) (int64) 1376 if t.PreCommitEpoch >= 0 { 1377 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.PreCommitEpoch)); err != nil { 1378 return err 1379 } 1380 } else { 1381 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.PreCommitEpoch-1)); err != nil { 1382 return err 1383 } 1384 } 1385 1386 // t.DealWeight (big.Int) (struct) 1387 if err := t.DealWeight.MarshalCBOR(w); err != nil { 1388 return err 1389 } 1390 1391 // t.VerifiedDealWeight (big.Int) (struct) 1392 if err := t.VerifiedDealWeight.MarshalCBOR(w); err != nil { 1393 return err 1394 } 1395 return nil 1396 } 1397 1398 func (t *SectorPreCommitOnChainInfo) UnmarshalCBOR(r io.Reader) error { 1399 *t = SectorPreCommitOnChainInfo{} 1400 1401 br := cbg.GetPeeker(r) 1402 scratch := make([]byte, 8) 1403 1404 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 1405 if err != nil { 1406 return err 1407 } 1408 if maj != cbg.MajArray { 1409 return fmt.Errorf("cbor input should be of type array") 1410 } 1411 1412 if extra != 5 { 1413 return fmt.Errorf("cbor input had wrong number of fields") 1414 } 1415 1416 // t.Info (miner.SectorPreCommitInfo) (struct) 1417 1418 { 1419 1420 if err := t.Info.UnmarshalCBOR(br); err != nil { 1421 return xerrors.Errorf("unmarshaling t.Info: %w", err) 1422 } 1423 1424 } 1425 // t.PreCommitDeposit (big.Int) (struct) 1426 1427 { 1428 1429 if err := t.PreCommitDeposit.UnmarshalCBOR(br); err != nil { 1430 return xerrors.Errorf("unmarshaling t.PreCommitDeposit: %w", err) 1431 } 1432 1433 } 1434 // t.PreCommitEpoch (abi.ChainEpoch) (int64) 1435 { 1436 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 1437 var extraI int64 1438 if err != nil { 1439 return err 1440 } 1441 switch maj { 1442 case cbg.MajUnsignedInt: 1443 extraI = int64(extra) 1444 if extraI < 0 { 1445 return fmt.Errorf("int64 positive overflow") 1446 } 1447 case cbg.MajNegativeInt: 1448 extraI = int64(extra) 1449 if extraI < 0 { 1450 return fmt.Errorf("int64 negative oveflow") 1451 } 1452 extraI = -1 - extraI 1453 default: 1454 return fmt.Errorf("wrong type for int64 field: %d", maj) 1455 } 1456 1457 t.PreCommitEpoch = abi.ChainEpoch(extraI) 1458 } 1459 // t.DealWeight (big.Int) (struct) 1460 1461 { 1462 1463 if err := t.DealWeight.UnmarshalCBOR(br); err != nil { 1464 return xerrors.Errorf("unmarshaling t.DealWeight: %w", err) 1465 } 1466 1467 } 1468 // t.VerifiedDealWeight (big.Int) (struct) 1469 1470 { 1471 1472 if err := t.VerifiedDealWeight.UnmarshalCBOR(br); err != nil { 1473 return xerrors.Errorf("unmarshaling t.VerifiedDealWeight: %w", err) 1474 } 1475 1476 } 1477 return nil 1478 } 1479 1480 var lengthBufSectorPreCommitInfo = []byte{138} 1481 1482 func (t *SectorPreCommitInfo) MarshalCBOR(w io.Writer) error { 1483 if t == nil { 1484 _, err := w.Write(cbg.CborNull) 1485 return err 1486 } 1487 if _, err := w.Write(lengthBufSectorPreCommitInfo); err != nil { 1488 return err 1489 } 1490 1491 scratch := make([]byte, 9) 1492 1493 // t.SealProof (abi.RegisteredSealProof) (int64) 1494 if t.SealProof >= 0 { 1495 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.SealProof)); err != nil { 1496 return err 1497 } 1498 } else { 1499 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.SealProof-1)); err != nil { 1500 return err 1501 } 1502 } 1503 1504 // t.SectorNumber (abi.SectorNumber) (uint64) 1505 1506 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.SectorNumber)); err != nil { 1507 return err 1508 } 1509 1510 // t.SealedCID (cid.Cid) (struct) 1511 1512 if err := cbg.WriteCidBuf(scratch, w, t.SealedCID); err != nil { 1513 return xerrors.Errorf("failed to write cid field t.SealedCID: %w", err) 1514 } 1515 1516 // t.SealRandEpoch (abi.ChainEpoch) (int64) 1517 if t.SealRandEpoch >= 0 { 1518 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.SealRandEpoch)); err != nil { 1519 return err 1520 } 1521 } else { 1522 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.SealRandEpoch-1)); err != nil { 1523 return err 1524 } 1525 } 1526 1527 // t.DealIDs ([]abi.DealID) (slice) 1528 if len(t.DealIDs) > cbg.MaxLength { 1529 return xerrors.Errorf("Slice value in field t.DealIDs was too long") 1530 } 1531 1532 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.DealIDs))); err != nil { 1533 return err 1534 } 1535 for _, v := range t.DealIDs { 1536 if err := cbg.CborWriteHeader(w, cbg.MajUnsignedInt, uint64(v)); err != nil { 1537 return err 1538 } 1539 } 1540 1541 // t.Expiration (abi.ChainEpoch) (int64) 1542 if t.Expiration >= 0 { 1543 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Expiration)); err != nil { 1544 return err 1545 } 1546 } else { 1547 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.Expiration-1)); err != nil { 1548 return err 1549 } 1550 } 1551 1552 // t.ReplaceCapacity (bool) (bool) 1553 if err := cbg.WriteBool(w, t.ReplaceCapacity); err != nil { 1554 return err 1555 } 1556 1557 // t.ReplaceSectorDeadline (uint64) (uint64) 1558 1559 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.ReplaceSectorDeadline)); err != nil { 1560 return err 1561 } 1562 1563 // t.ReplaceSectorPartition (uint64) (uint64) 1564 1565 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.ReplaceSectorPartition)); err != nil { 1566 return err 1567 } 1568 1569 // t.ReplaceSectorNumber (abi.SectorNumber) (uint64) 1570 1571 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.ReplaceSectorNumber)); err != nil { 1572 return err 1573 } 1574 1575 return nil 1576 } 1577 1578 func (t *SectorPreCommitInfo) UnmarshalCBOR(r io.Reader) error { 1579 *t = SectorPreCommitInfo{} 1580 1581 br := cbg.GetPeeker(r) 1582 scratch := make([]byte, 8) 1583 1584 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 1585 if err != nil { 1586 return err 1587 } 1588 if maj != cbg.MajArray { 1589 return fmt.Errorf("cbor input should be of type array") 1590 } 1591 1592 if extra != 10 { 1593 return fmt.Errorf("cbor input had wrong number of fields") 1594 } 1595 1596 // t.SealProof (abi.RegisteredSealProof) (int64) 1597 { 1598 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 1599 var extraI int64 1600 if err != nil { 1601 return err 1602 } 1603 switch maj { 1604 case cbg.MajUnsignedInt: 1605 extraI = int64(extra) 1606 if extraI < 0 { 1607 return fmt.Errorf("int64 positive overflow") 1608 } 1609 case cbg.MajNegativeInt: 1610 extraI = int64(extra) 1611 if extraI < 0 { 1612 return fmt.Errorf("int64 negative oveflow") 1613 } 1614 extraI = -1 - extraI 1615 default: 1616 return fmt.Errorf("wrong type for int64 field: %d", maj) 1617 } 1618 1619 t.SealProof = abi.RegisteredSealProof(extraI) 1620 } 1621 // t.SectorNumber (abi.SectorNumber) (uint64) 1622 1623 { 1624 1625 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 1626 if err != nil { 1627 return err 1628 } 1629 if maj != cbg.MajUnsignedInt { 1630 return fmt.Errorf("wrong type for uint64 field") 1631 } 1632 t.SectorNumber = abi.SectorNumber(extra) 1633 1634 } 1635 // t.SealedCID (cid.Cid) (struct) 1636 1637 { 1638 1639 c, err := cbg.ReadCid(br) 1640 if err != nil { 1641 return xerrors.Errorf("failed to read cid field t.SealedCID: %w", err) 1642 } 1643 1644 t.SealedCID = c 1645 1646 } 1647 // t.SealRandEpoch (abi.ChainEpoch) (int64) 1648 { 1649 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 1650 var extraI int64 1651 if err != nil { 1652 return err 1653 } 1654 switch maj { 1655 case cbg.MajUnsignedInt: 1656 extraI = int64(extra) 1657 if extraI < 0 { 1658 return fmt.Errorf("int64 positive overflow") 1659 } 1660 case cbg.MajNegativeInt: 1661 extraI = int64(extra) 1662 if extraI < 0 { 1663 return fmt.Errorf("int64 negative oveflow") 1664 } 1665 extraI = -1 - extraI 1666 default: 1667 return fmt.Errorf("wrong type for int64 field: %d", maj) 1668 } 1669 1670 t.SealRandEpoch = abi.ChainEpoch(extraI) 1671 } 1672 // t.DealIDs ([]abi.DealID) (slice) 1673 1674 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 1675 if err != nil { 1676 return err 1677 } 1678 1679 if extra > cbg.MaxLength { 1680 return fmt.Errorf("t.DealIDs: array too large (%d)", extra) 1681 } 1682 1683 if maj != cbg.MajArray { 1684 return fmt.Errorf("expected cbor array") 1685 } 1686 1687 if extra > 0 { 1688 t.DealIDs = make([]abi.DealID, extra) 1689 } 1690 1691 for i := 0; i < int(extra); i++ { 1692 1693 maj, val, err := cbg.CborReadHeaderBuf(br, scratch) 1694 if err != nil { 1695 return xerrors.Errorf("failed to read uint64 for t.DealIDs slice: %w", err) 1696 } 1697 1698 if maj != cbg.MajUnsignedInt { 1699 return xerrors.Errorf("value read for array t.DealIDs was not a uint, instead got %d", maj) 1700 } 1701 1702 t.DealIDs[i] = abi.DealID(val) 1703 } 1704 1705 // t.Expiration (abi.ChainEpoch) (int64) 1706 { 1707 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 1708 var extraI int64 1709 if err != nil { 1710 return err 1711 } 1712 switch maj { 1713 case cbg.MajUnsignedInt: 1714 extraI = int64(extra) 1715 if extraI < 0 { 1716 return fmt.Errorf("int64 positive overflow") 1717 } 1718 case cbg.MajNegativeInt: 1719 extraI = int64(extra) 1720 if extraI < 0 { 1721 return fmt.Errorf("int64 negative oveflow") 1722 } 1723 extraI = -1 - extraI 1724 default: 1725 return fmt.Errorf("wrong type for int64 field: %d", maj) 1726 } 1727 1728 t.Expiration = abi.ChainEpoch(extraI) 1729 } 1730 // t.ReplaceCapacity (bool) (bool) 1731 1732 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 1733 if err != nil { 1734 return err 1735 } 1736 if maj != cbg.MajOther { 1737 return fmt.Errorf("booleans must be major type 7") 1738 } 1739 switch extra { 1740 case 20: 1741 t.ReplaceCapacity = false 1742 case 21: 1743 t.ReplaceCapacity = true 1744 default: 1745 return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) 1746 } 1747 // t.ReplaceSectorDeadline (uint64) (uint64) 1748 1749 { 1750 1751 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 1752 if err != nil { 1753 return err 1754 } 1755 if maj != cbg.MajUnsignedInt { 1756 return fmt.Errorf("wrong type for uint64 field") 1757 } 1758 t.ReplaceSectorDeadline = uint64(extra) 1759 1760 } 1761 // t.ReplaceSectorPartition (uint64) (uint64) 1762 1763 { 1764 1765 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 1766 if err != nil { 1767 return err 1768 } 1769 if maj != cbg.MajUnsignedInt { 1770 return fmt.Errorf("wrong type for uint64 field") 1771 } 1772 t.ReplaceSectorPartition = uint64(extra) 1773 1774 } 1775 // t.ReplaceSectorNumber (abi.SectorNumber) (uint64) 1776 1777 { 1778 1779 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 1780 if err != nil { 1781 return err 1782 } 1783 if maj != cbg.MajUnsignedInt { 1784 return fmt.Errorf("wrong type for uint64 field") 1785 } 1786 t.ReplaceSectorNumber = abi.SectorNumber(extra) 1787 1788 } 1789 return nil 1790 } 1791 1792 var lengthBufSectorOnChainInfo = []byte{141} 1793 1794 func (t *SectorOnChainInfo) MarshalCBOR(w io.Writer) error { 1795 if t == nil { 1796 _, err := w.Write(cbg.CborNull) 1797 return err 1798 } 1799 if _, err := w.Write(lengthBufSectorOnChainInfo); err != nil { 1800 return err 1801 } 1802 1803 scratch := make([]byte, 9) 1804 1805 // t.SectorNumber (abi.SectorNumber) (uint64) 1806 1807 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.SectorNumber)); err != nil { 1808 return err 1809 } 1810 1811 // t.SealProof (abi.RegisteredSealProof) (int64) 1812 if t.SealProof >= 0 { 1813 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.SealProof)); err != nil { 1814 return err 1815 } 1816 } else { 1817 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.SealProof-1)); err != nil { 1818 return err 1819 } 1820 } 1821 1822 // t.SealedCID (cid.Cid) (struct) 1823 1824 if err := cbg.WriteCidBuf(scratch, w, t.SealedCID); err != nil { 1825 return xerrors.Errorf("failed to write cid field t.SealedCID: %w", err) 1826 } 1827 1828 // t.DealIDs ([]abi.DealID) (slice) 1829 if len(t.DealIDs) > cbg.MaxLength { 1830 return xerrors.Errorf("Slice value in field t.DealIDs was too long") 1831 } 1832 1833 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.DealIDs))); err != nil { 1834 return err 1835 } 1836 for _, v := range t.DealIDs { 1837 if err := cbg.CborWriteHeader(w, cbg.MajUnsignedInt, uint64(v)); err != nil { 1838 return err 1839 } 1840 } 1841 1842 // t.Activation (abi.ChainEpoch) (int64) 1843 if t.Activation >= 0 { 1844 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Activation)); err != nil { 1845 return err 1846 } 1847 } else { 1848 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.Activation-1)); err != nil { 1849 return err 1850 } 1851 } 1852 1853 // t.Expiration (abi.ChainEpoch) (int64) 1854 if t.Expiration >= 0 { 1855 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Expiration)); err != nil { 1856 return err 1857 } 1858 } else { 1859 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.Expiration-1)); err != nil { 1860 return err 1861 } 1862 } 1863 1864 // t.DealWeight (big.Int) (struct) 1865 if err := t.DealWeight.MarshalCBOR(w); err != nil { 1866 return err 1867 } 1868 1869 // t.VerifiedDealWeight (big.Int) (struct) 1870 if err := t.VerifiedDealWeight.MarshalCBOR(w); err != nil { 1871 return err 1872 } 1873 1874 // t.InitialPledge (big.Int) (struct) 1875 if err := t.InitialPledge.MarshalCBOR(w); err != nil { 1876 return err 1877 } 1878 1879 // t.ExpectedDayReward (big.Int) (struct) 1880 if err := t.ExpectedDayReward.MarshalCBOR(w); err != nil { 1881 return err 1882 } 1883 1884 // t.ExpectedStoragePledge (big.Int) (struct) 1885 if err := t.ExpectedStoragePledge.MarshalCBOR(w); err != nil { 1886 return err 1887 } 1888 1889 // t.ReplacedSectorAge (abi.ChainEpoch) (int64) 1890 if t.ReplacedSectorAge >= 0 { 1891 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.ReplacedSectorAge)); err != nil { 1892 return err 1893 } 1894 } else { 1895 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.ReplacedSectorAge-1)); err != nil { 1896 return err 1897 } 1898 } 1899 1900 // t.ReplacedDayReward (big.Int) (struct) 1901 if err := t.ReplacedDayReward.MarshalCBOR(w); err != nil { 1902 return err 1903 } 1904 return nil 1905 } 1906 1907 func (t *SectorOnChainInfo) UnmarshalCBOR(r io.Reader) error { 1908 *t = SectorOnChainInfo{} 1909 1910 br := cbg.GetPeeker(r) 1911 scratch := make([]byte, 8) 1912 1913 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 1914 if err != nil { 1915 return err 1916 } 1917 if maj != cbg.MajArray { 1918 return fmt.Errorf("cbor input should be of type array") 1919 } 1920 1921 if extra != 13 { 1922 return fmt.Errorf("cbor input had wrong number of fields") 1923 } 1924 1925 // t.SectorNumber (abi.SectorNumber) (uint64) 1926 1927 { 1928 1929 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 1930 if err != nil { 1931 return err 1932 } 1933 if maj != cbg.MajUnsignedInt { 1934 return fmt.Errorf("wrong type for uint64 field") 1935 } 1936 t.SectorNumber = abi.SectorNumber(extra) 1937 1938 } 1939 // t.SealProof (abi.RegisteredSealProof) (int64) 1940 { 1941 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 1942 var extraI int64 1943 if err != nil { 1944 return err 1945 } 1946 switch maj { 1947 case cbg.MajUnsignedInt: 1948 extraI = int64(extra) 1949 if extraI < 0 { 1950 return fmt.Errorf("int64 positive overflow") 1951 } 1952 case cbg.MajNegativeInt: 1953 extraI = int64(extra) 1954 if extraI < 0 { 1955 return fmt.Errorf("int64 negative oveflow") 1956 } 1957 extraI = -1 - extraI 1958 default: 1959 return fmt.Errorf("wrong type for int64 field: %d", maj) 1960 } 1961 1962 t.SealProof = abi.RegisteredSealProof(extraI) 1963 } 1964 // t.SealedCID (cid.Cid) (struct) 1965 1966 { 1967 1968 c, err := cbg.ReadCid(br) 1969 if err != nil { 1970 return xerrors.Errorf("failed to read cid field t.SealedCID: %w", err) 1971 } 1972 1973 t.SealedCID = c 1974 1975 } 1976 // t.DealIDs ([]abi.DealID) (slice) 1977 1978 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 1979 if err != nil { 1980 return err 1981 } 1982 1983 if extra > cbg.MaxLength { 1984 return fmt.Errorf("t.DealIDs: array too large (%d)", extra) 1985 } 1986 1987 if maj != cbg.MajArray { 1988 return fmt.Errorf("expected cbor array") 1989 } 1990 1991 if extra > 0 { 1992 t.DealIDs = make([]abi.DealID, extra) 1993 } 1994 1995 for i := 0; i < int(extra); i++ { 1996 1997 maj, val, err := cbg.CborReadHeaderBuf(br, scratch) 1998 if err != nil { 1999 return xerrors.Errorf("failed to read uint64 for t.DealIDs slice: %w", err) 2000 } 2001 2002 if maj != cbg.MajUnsignedInt { 2003 return xerrors.Errorf("value read for array t.DealIDs was not a uint, instead got %d", maj) 2004 } 2005 2006 t.DealIDs[i] = abi.DealID(val) 2007 } 2008 2009 // t.Activation (abi.ChainEpoch) (int64) 2010 { 2011 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 2012 var extraI int64 2013 if err != nil { 2014 return err 2015 } 2016 switch maj { 2017 case cbg.MajUnsignedInt: 2018 extraI = int64(extra) 2019 if extraI < 0 { 2020 return fmt.Errorf("int64 positive overflow") 2021 } 2022 case cbg.MajNegativeInt: 2023 extraI = int64(extra) 2024 if extraI < 0 { 2025 return fmt.Errorf("int64 negative oveflow") 2026 } 2027 extraI = -1 - extraI 2028 default: 2029 return fmt.Errorf("wrong type for int64 field: %d", maj) 2030 } 2031 2032 t.Activation = abi.ChainEpoch(extraI) 2033 } 2034 // t.Expiration (abi.ChainEpoch) (int64) 2035 { 2036 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 2037 var extraI int64 2038 if err != nil { 2039 return err 2040 } 2041 switch maj { 2042 case cbg.MajUnsignedInt: 2043 extraI = int64(extra) 2044 if extraI < 0 { 2045 return fmt.Errorf("int64 positive overflow") 2046 } 2047 case cbg.MajNegativeInt: 2048 extraI = int64(extra) 2049 if extraI < 0 { 2050 return fmt.Errorf("int64 negative oveflow") 2051 } 2052 extraI = -1 - extraI 2053 default: 2054 return fmt.Errorf("wrong type for int64 field: %d", maj) 2055 } 2056 2057 t.Expiration = abi.ChainEpoch(extraI) 2058 } 2059 // t.DealWeight (big.Int) (struct) 2060 2061 { 2062 2063 if err := t.DealWeight.UnmarshalCBOR(br); err != nil { 2064 return xerrors.Errorf("unmarshaling t.DealWeight: %w", err) 2065 } 2066 2067 } 2068 // t.VerifiedDealWeight (big.Int) (struct) 2069 2070 { 2071 2072 if err := t.VerifiedDealWeight.UnmarshalCBOR(br); err != nil { 2073 return xerrors.Errorf("unmarshaling t.VerifiedDealWeight: %w", err) 2074 } 2075 2076 } 2077 // t.InitialPledge (big.Int) (struct) 2078 2079 { 2080 2081 if err := t.InitialPledge.UnmarshalCBOR(br); err != nil { 2082 return xerrors.Errorf("unmarshaling t.InitialPledge: %w", err) 2083 } 2084 2085 } 2086 // t.ExpectedDayReward (big.Int) (struct) 2087 2088 { 2089 2090 if err := t.ExpectedDayReward.UnmarshalCBOR(br); err != nil { 2091 return xerrors.Errorf("unmarshaling t.ExpectedDayReward: %w", err) 2092 } 2093 2094 } 2095 // t.ExpectedStoragePledge (big.Int) (struct) 2096 2097 { 2098 2099 if err := t.ExpectedStoragePledge.UnmarshalCBOR(br); err != nil { 2100 return xerrors.Errorf("unmarshaling t.ExpectedStoragePledge: %w", err) 2101 } 2102 2103 } 2104 // t.ReplacedSectorAge (abi.ChainEpoch) (int64) 2105 { 2106 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 2107 var extraI int64 2108 if err != nil { 2109 return err 2110 } 2111 switch maj { 2112 case cbg.MajUnsignedInt: 2113 extraI = int64(extra) 2114 if extraI < 0 { 2115 return fmt.Errorf("int64 positive overflow") 2116 } 2117 case cbg.MajNegativeInt: 2118 extraI = int64(extra) 2119 if extraI < 0 { 2120 return fmt.Errorf("int64 negative oveflow") 2121 } 2122 extraI = -1 - extraI 2123 default: 2124 return fmt.Errorf("wrong type for int64 field: %d", maj) 2125 } 2126 2127 t.ReplacedSectorAge = abi.ChainEpoch(extraI) 2128 } 2129 // t.ReplacedDayReward (big.Int) (struct) 2130 2131 { 2132 2133 if err := t.ReplacedDayReward.UnmarshalCBOR(br); err != nil { 2134 return xerrors.Errorf("unmarshaling t.ReplacedDayReward: %w", err) 2135 } 2136 2137 } 2138 return nil 2139 } 2140 2141 var lengthBufWorkerKeyChange = []byte{130} 2142 2143 func (t *WorkerKeyChange) MarshalCBOR(w io.Writer) error { 2144 if t == nil { 2145 _, err := w.Write(cbg.CborNull) 2146 return err 2147 } 2148 if _, err := w.Write(lengthBufWorkerKeyChange); err != nil { 2149 return err 2150 } 2151 2152 scratch := make([]byte, 9) 2153 2154 // t.NewWorker (address.Address) (struct) 2155 if err := t.NewWorker.MarshalCBOR(w); err != nil { 2156 return err 2157 } 2158 2159 // t.EffectiveAt (abi.ChainEpoch) (int64) 2160 if t.EffectiveAt >= 0 { 2161 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.EffectiveAt)); err != nil { 2162 return err 2163 } 2164 } else { 2165 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.EffectiveAt-1)); err != nil { 2166 return err 2167 } 2168 } 2169 return nil 2170 } 2171 2172 func (t *WorkerKeyChange) UnmarshalCBOR(r io.Reader) error { 2173 *t = WorkerKeyChange{} 2174 2175 br := cbg.GetPeeker(r) 2176 scratch := make([]byte, 8) 2177 2178 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 2179 if err != nil { 2180 return err 2181 } 2182 if maj != cbg.MajArray { 2183 return fmt.Errorf("cbor input should be of type array") 2184 } 2185 2186 if extra != 2 { 2187 return fmt.Errorf("cbor input had wrong number of fields") 2188 } 2189 2190 // t.NewWorker (address.Address) (struct) 2191 2192 { 2193 2194 if err := t.NewWorker.UnmarshalCBOR(br); err != nil { 2195 return xerrors.Errorf("unmarshaling t.NewWorker: %w", err) 2196 } 2197 2198 } 2199 // t.EffectiveAt (abi.ChainEpoch) (int64) 2200 { 2201 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 2202 var extraI int64 2203 if err != nil { 2204 return err 2205 } 2206 switch maj { 2207 case cbg.MajUnsignedInt: 2208 extraI = int64(extra) 2209 if extraI < 0 { 2210 return fmt.Errorf("int64 positive overflow") 2211 } 2212 case cbg.MajNegativeInt: 2213 extraI = int64(extra) 2214 if extraI < 0 { 2215 return fmt.Errorf("int64 negative oveflow") 2216 } 2217 extraI = -1 - extraI 2218 default: 2219 return fmt.Errorf("wrong type for int64 field: %d", maj) 2220 } 2221 2222 t.EffectiveAt = abi.ChainEpoch(extraI) 2223 } 2224 return nil 2225 } 2226 2227 var lengthBufVestingFunds = []byte{129} 2228 2229 func (t *VestingFunds) MarshalCBOR(w io.Writer) error { 2230 if t == nil { 2231 _, err := w.Write(cbg.CborNull) 2232 return err 2233 } 2234 if _, err := w.Write(lengthBufVestingFunds); err != nil { 2235 return err 2236 } 2237 2238 scratch := make([]byte, 9) 2239 2240 // t.Funds ([]miner.VestingFund) (slice) 2241 if len(t.Funds) > cbg.MaxLength { 2242 return xerrors.Errorf("Slice value in field t.Funds was too long") 2243 } 2244 2245 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Funds))); err != nil { 2246 return err 2247 } 2248 for _, v := range t.Funds { 2249 if err := v.MarshalCBOR(w); err != nil { 2250 return err 2251 } 2252 } 2253 return nil 2254 } 2255 2256 func (t *VestingFunds) UnmarshalCBOR(r io.Reader) error { 2257 *t = VestingFunds{} 2258 2259 br := cbg.GetPeeker(r) 2260 scratch := make([]byte, 8) 2261 2262 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 2263 if err != nil { 2264 return err 2265 } 2266 if maj != cbg.MajArray { 2267 return fmt.Errorf("cbor input should be of type array") 2268 } 2269 2270 if extra != 1 { 2271 return fmt.Errorf("cbor input had wrong number of fields") 2272 } 2273 2274 // t.Funds ([]miner.VestingFund) (slice) 2275 2276 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 2277 if err != nil { 2278 return err 2279 } 2280 2281 if extra > cbg.MaxLength { 2282 return fmt.Errorf("t.Funds: array too large (%d)", extra) 2283 } 2284 2285 if maj != cbg.MajArray { 2286 return fmt.Errorf("expected cbor array") 2287 } 2288 2289 if extra > 0 { 2290 t.Funds = make([]VestingFund, extra) 2291 } 2292 2293 for i := 0; i < int(extra); i++ { 2294 2295 var v VestingFund 2296 if err := v.UnmarshalCBOR(br); err != nil { 2297 return err 2298 } 2299 2300 t.Funds[i] = v 2301 } 2302 2303 return nil 2304 } 2305 2306 var lengthBufVestingFund = []byte{130} 2307 2308 func (t *VestingFund) MarshalCBOR(w io.Writer) error { 2309 if t == nil { 2310 _, err := w.Write(cbg.CborNull) 2311 return err 2312 } 2313 if _, err := w.Write(lengthBufVestingFund); err != nil { 2314 return err 2315 } 2316 2317 scratch := make([]byte, 9) 2318 2319 // t.Epoch (abi.ChainEpoch) (int64) 2320 if t.Epoch >= 0 { 2321 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Epoch)); err != nil { 2322 return err 2323 } 2324 } else { 2325 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.Epoch-1)); err != nil { 2326 return err 2327 } 2328 } 2329 2330 // t.Amount (big.Int) (struct) 2331 if err := t.Amount.MarshalCBOR(w); err != nil { 2332 return err 2333 } 2334 return nil 2335 } 2336 2337 func (t *VestingFund) UnmarshalCBOR(r io.Reader) error { 2338 *t = VestingFund{} 2339 2340 br := cbg.GetPeeker(r) 2341 scratch := make([]byte, 8) 2342 2343 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 2344 if err != nil { 2345 return err 2346 } 2347 if maj != cbg.MajArray { 2348 return fmt.Errorf("cbor input should be of type array") 2349 } 2350 2351 if extra != 2 { 2352 return fmt.Errorf("cbor input had wrong number of fields") 2353 } 2354 2355 // t.Epoch (abi.ChainEpoch) (int64) 2356 { 2357 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 2358 var extraI int64 2359 if err != nil { 2360 return err 2361 } 2362 switch maj { 2363 case cbg.MajUnsignedInt: 2364 extraI = int64(extra) 2365 if extraI < 0 { 2366 return fmt.Errorf("int64 positive overflow") 2367 } 2368 case cbg.MajNegativeInt: 2369 extraI = int64(extra) 2370 if extraI < 0 { 2371 return fmt.Errorf("int64 negative oveflow") 2372 } 2373 extraI = -1 - extraI 2374 default: 2375 return fmt.Errorf("wrong type for int64 field: %d", maj) 2376 } 2377 2378 t.Epoch = abi.ChainEpoch(extraI) 2379 } 2380 // t.Amount (big.Int) (struct) 2381 2382 { 2383 2384 if err := t.Amount.UnmarshalCBOR(br); err != nil { 2385 return xerrors.Errorf("unmarshaling t.Amount: %w", err) 2386 } 2387 2388 } 2389 return nil 2390 } 2391 2392 var lengthBufWindowedPoSt = []byte{130} 2393 2394 func (t *WindowedPoSt) MarshalCBOR(w io.Writer) error { 2395 if t == nil { 2396 _, err := w.Write(cbg.CborNull) 2397 return err 2398 } 2399 if _, err := w.Write(lengthBufWindowedPoSt); err != nil { 2400 return err 2401 } 2402 2403 scratch := make([]byte, 9) 2404 2405 // t.Partitions (bitfield.BitField) (struct) 2406 if err := t.Partitions.MarshalCBOR(w); err != nil { 2407 return err 2408 } 2409 2410 // t.Proofs ([]proof.PoStProof) (slice) 2411 if len(t.Proofs) > cbg.MaxLength { 2412 return xerrors.Errorf("Slice value in field t.Proofs was too long") 2413 } 2414 2415 if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Proofs))); err != nil { 2416 return err 2417 } 2418 for _, v := range t.Proofs { 2419 if err := v.MarshalCBOR(w); err != nil { 2420 return err 2421 } 2422 } 2423 return nil 2424 } 2425 2426 func (t *WindowedPoSt) UnmarshalCBOR(r io.Reader) error { 2427 *t = WindowedPoSt{} 2428 2429 br := cbg.GetPeeker(r) 2430 scratch := make([]byte, 8) 2431 2432 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 2433 if err != nil { 2434 return err 2435 } 2436 if maj != cbg.MajArray { 2437 return fmt.Errorf("cbor input should be of type array") 2438 } 2439 2440 if extra != 2 { 2441 return fmt.Errorf("cbor input had wrong number of fields") 2442 } 2443 2444 // t.Partitions (bitfield.BitField) (struct) 2445 2446 { 2447 2448 if err := t.Partitions.UnmarshalCBOR(br); err != nil { 2449 return xerrors.Errorf("unmarshaling t.Partitions: %w", err) 2450 } 2451 2452 } 2453 // t.Proofs ([]proof.PoStProof) (slice) 2454 2455 maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) 2456 if err != nil { 2457 return err 2458 } 2459 2460 if extra > cbg.MaxLength { 2461 return fmt.Errorf("t.Proofs: array too large (%d)", extra) 2462 } 2463 2464 if maj != cbg.MajArray { 2465 return fmt.Errorf("expected cbor array") 2466 } 2467 2468 if extra > 0 { 2469 t.Proofs = make([]proof.PoStProof, extra) 2470 } 2471 2472 for i := 0; i < int(extra); i++ { 2473 2474 var v proof.PoStProof 2475 if err := v.UnmarshalCBOR(br); err != nil { 2476 return err 2477 } 2478 2479 t.Proofs[i] = v 2480 } 2481 2482 return nil 2483 }