package storage import ( "fmt" "io" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" ) /* This file was generated by github.com/whyrusleeping/cbor-gen */ var _ = xerrors.Errorf func (t *SealTicket) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } if _, err := w.Write([]byte{130}); err != nil { return err } // t.t.BlockHeight (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.BlockHeight))); err != nil { return err } // t.t.TicketBytes ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.TicketBytes)))); err != nil { return err } if _, err := w.Write(t.TicketBytes); err != nil { return err } return nil } func (t *SealTicket) UnmarshalCBOR(r io.Reader) error { br := cbg.GetPeeker(r) maj, extra, err := cbg.CborReadHeader(br) if err != nil { return err } if maj != cbg.MajArray { return fmt.Errorf("cbor input should be of type array") } if extra != 2 { return fmt.Errorf("cbor input had wrong number of fields") } // t.t.BlockHeight (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { return err } if maj != cbg.MajUnsignedInt { return fmt.Errorf("wrong type for uint64 field") } t.BlockHeight = uint64(extra) // t.t.TicketBytes ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { return err } if extra > cbg.ByteArrayMaxLen { return fmt.Errorf("t.TicketBytes: byte array too large (%d)", extra) } if maj != cbg.MajByteString { return fmt.Errorf("expected byte array") } t.TicketBytes = make([]byte, extra) if _, err := io.ReadFull(br, t.TicketBytes); err != nil { return err } return nil } func (t *SealSeed) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } if _, err := w.Write([]byte{130}); err != nil { return err } // t.t.BlockHeight (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.BlockHeight))); err != nil { return err } // t.t.TicketBytes ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.TicketBytes)))); err != nil { return err } if _, err := w.Write(t.TicketBytes); err != nil { return err } return nil } func (t *SealSeed) UnmarshalCBOR(r io.Reader) error { br := cbg.GetPeeker(r) maj, extra, err := cbg.CborReadHeader(br) if err != nil { return err } if maj != cbg.MajArray { return fmt.Errorf("cbor input should be of type array") } if extra != 2 { return fmt.Errorf("cbor input had wrong number of fields") } // t.t.BlockHeight (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { return err } if maj != cbg.MajUnsignedInt { return fmt.Errorf("wrong type for uint64 field") } t.BlockHeight = uint64(extra) // t.t.TicketBytes ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { return err } if extra > cbg.ByteArrayMaxLen { return fmt.Errorf("t.TicketBytes: byte array too large (%d)", extra) } if maj != cbg.MajByteString { return fmt.Errorf("expected byte array") } t.TicketBytes = make([]byte, extra) if _, err := io.ReadFull(br, t.TicketBytes); err != nil { return err } return nil } func (t *Piece) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } if _, err := w.Write([]byte{131}); err != nil { return err } // t.t.DealID (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.DealID))); err != nil { return err } // t.t.Size (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Size))); err != nil { return err } // t.t.CommP ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.CommP)))); err != nil { return err } if _, err := w.Write(t.CommP); err != nil { return err } return nil } func (t *Piece) UnmarshalCBOR(r io.Reader) error { br := cbg.GetPeeker(r) maj, extra, err := cbg.CborReadHeader(br) if err != nil { return err } if maj != cbg.MajArray { return fmt.Errorf("cbor input should be of type array") } if extra != 3 { return fmt.Errorf("cbor input had wrong number of fields") } // t.t.DealID (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { return err } if maj != cbg.MajUnsignedInt { return fmt.Errorf("wrong type for uint64 field") } t.DealID = uint64(extra) // t.t.Size (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { return err } if maj != cbg.MajUnsignedInt { return fmt.Errorf("wrong type for uint64 field") } t.Size = uint64(extra) // t.t.CommP ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { return err } if extra > cbg.ByteArrayMaxLen { return fmt.Errorf("t.CommP: byte array too large (%d)", extra) } if maj != cbg.MajByteString { return fmt.Errorf("expected byte array") } t.CommP = make([]byte, extra) if _, err := io.ReadFull(br, t.CommP); err != nil { return err } return nil } func (t *SectorInfo) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } if _, err := w.Write([]byte{142}); err != nil { return err } // t.t.State (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.State))); err != nil { return err } // t.t.SectorID (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorID))); err != nil { return err } // t.t.Nonce (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Nonce))); err != nil { return err } // t.t.Pieces ([]storage.Piece) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Pieces)))); err != nil { return err } for _, v := range t.Pieces { if err := v.MarshalCBOR(w); err != nil { return err } } // t.t.Pad0 ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Pad0)))); err != nil { return err } if _, err := w.Write(t.Pad0); err != nil { return err } // t.t.CommD ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.CommD)))); err != nil { return err } if _, err := w.Write(t.CommD); err != nil { return err } // t.t.CommR ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.CommR)))); err != nil { return err } if _, err := w.Write(t.CommR); err != nil { return err } // t.t.Pad1 ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Pad1)))); err != nil { return err } if _, err := w.Write(t.Pad1); err != nil { return err } // t.t.Proof ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Proof)))); err != nil { return err } if _, err := w.Write(t.Proof); err != nil { return err } // t.t.Ticket (storage.SealTicket) (struct) if err := t.Ticket.MarshalCBOR(w); err != nil { return err } // t.t.PreCommitMessage (cid.Cid) (struct) if t.PreCommitMessage == nil { if _, err := w.Write(cbg.CborNull); err != nil { return err } } else { if err := cbg.WriteCid(w, *t.PreCommitMessage); err != nil { return xerrors.Errorf("failed to write cid field t.PreCommitMessage: %w", err) } } // t.t.Seed (storage.SealSeed) (struct) if err := t.Seed.MarshalCBOR(w); err != nil { return err } // t.t.CommitMessage (cid.Cid) (struct) if t.CommitMessage == nil { if _, err := w.Write(cbg.CborNull); err != nil { return err } } else { if err := cbg.WriteCid(w, *t.CommitMessage); err != nil { return xerrors.Errorf("failed to write cid field t.CommitMessage: %w", err) } } // t.t.LastErr (string) (string) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.LastErr)))); err != nil { return err } if _, err := w.Write([]byte(t.LastErr)); err != nil { return err } return nil } func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error { br := cbg.GetPeeker(r) maj, extra, err := cbg.CborReadHeader(br) if err != nil { return err } if maj != cbg.MajArray { return fmt.Errorf("cbor input should be of type array") } if extra != 14 { return fmt.Errorf("cbor input had wrong number of fields") } // t.t.State (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { return err } if maj != cbg.MajUnsignedInt { return fmt.Errorf("wrong type for uint64 field") } t.State = uint64(extra) // t.t.SectorID (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { return err } if maj != cbg.MajUnsignedInt { return fmt.Errorf("wrong type for uint64 field") } t.SectorID = uint64(extra) // t.t.Nonce (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { return err } if maj != cbg.MajUnsignedInt { return fmt.Errorf("wrong type for uint64 field") } t.Nonce = uint64(extra) // t.t.Pieces ([]storage.Piece) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { return err } if extra > cbg.MaxLength { return fmt.Errorf("t.Pieces: array too large (%d)", extra) } if maj != cbg.MajArray { return fmt.Errorf("expected cbor array") } if extra > 0 { t.Pieces = make([]Piece, extra) } for i := 0; i < int(extra); i++ { var v Piece if err := v.UnmarshalCBOR(br); err != nil { return err } t.Pieces[i] = v } // t.t.Pad0 ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { return err } if extra > cbg.ByteArrayMaxLen { return fmt.Errorf("t.Pad0: byte array too large (%d)", extra) } if maj != cbg.MajByteString { return fmt.Errorf("expected byte array") } t.Pad0 = make([]byte, extra) if _, err := io.ReadFull(br, t.Pad0); err != nil { return err } // t.t.CommD ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { return err } if extra > cbg.ByteArrayMaxLen { return fmt.Errorf("t.CommD: byte array too large (%d)", extra) } if maj != cbg.MajByteString { return fmt.Errorf("expected byte array") } t.CommD = make([]byte, extra) if _, err := io.ReadFull(br, t.CommD); err != nil { return err } // t.t.CommR ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { return err } if extra > cbg.ByteArrayMaxLen { return fmt.Errorf("t.CommR: byte array too large (%d)", extra) } if maj != cbg.MajByteString { return fmt.Errorf("expected byte array") } t.CommR = make([]byte, extra) if _, err := io.ReadFull(br, t.CommR); err != nil { return err } // t.t.Pad1 ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { return err } if extra > cbg.ByteArrayMaxLen { return fmt.Errorf("t.Pad1: byte array too large (%d)", extra) } if maj != cbg.MajByteString { return fmt.Errorf("expected byte array") } t.Pad1 = make([]byte, extra) if _, err := io.ReadFull(br, t.Pad1); err != nil { return err } // t.t.Proof ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { return err } if extra > cbg.ByteArrayMaxLen { return fmt.Errorf("t.Proof: byte array too large (%d)", extra) } if maj != cbg.MajByteString { return fmt.Errorf("expected byte array") } t.Proof = make([]byte, extra) if _, err := io.ReadFull(br, t.Proof); err != nil { return err } // t.t.Ticket (storage.SealTicket) (struct) { if err := t.Ticket.UnmarshalCBOR(br); err != nil { return err } } // t.t.PreCommitMessage (cid.Cid) (struct) { pb, err := br.PeekByte() if err != nil { return err } if pb == cbg.CborNull[0] { var nbuf [1]byte if _, err := br.Read(nbuf[:]); err != nil { return err } } else { c, err := cbg.ReadCid(br) if err != nil { return xerrors.Errorf("failed to read cid field t.PreCommitMessage: %w", err) } t.PreCommitMessage = &c } } // t.t.Seed (storage.SealSeed) (struct) { if err := t.Seed.UnmarshalCBOR(br); err != nil { return err } } // t.t.CommitMessage (cid.Cid) (struct) { pb, err := br.PeekByte() if err != nil { return err } if pb == cbg.CborNull[0] { var nbuf [1]byte if _, err := br.Read(nbuf[:]); err != nil { return err } } else { c, err := cbg.ReadCid(br) if err != nil { return xerrors.Errorf("failed to read cid field t.CommitMessage: %w", err) } t.CommitMessage = &c } } // t.t.LastErr (string) (string) { sval, err := cbg.ReadString(br) if err != nil { return err } t.LastErr = string(sval) } return nil }