From 25bd37364cd8f608e9c76fdd4be42e60c4ac3cbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 3 Apr 2020 21:34:20 +0200 Subject: [PATCH] fsm: Update cbor-gen --- cbor_gen.go | 95 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 68 insertions(+), 27 deletions(-) diff --git a/cbor_gen.go b/cbor_gen.go index b69e95c68..2215914a9 100644 --- a/cbor_gen.go +++ b/cbor_gen.go @@ -178,7 +178,7 @@ func (t *SectorInfo) MarshalCBOR(w io.Writer) error { _, err := w.Write(cbg.CborNull) return err } - if _, err := w.Write([]byte{175}); err != nil { + if _, err := w.Write([]byte{176}); err != nil { return err } @@ -284,6 +284,45 @@ func (t *SectorInfo) MarshalCBOR(w io.Writer) error { } } + // t.Ticket (api.SealTicket) (struct) + if len("Ticket") > cbg.MaxLength { + return xerrors.Errorf("Value in field \"Ticket\" was too long") + } + + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Ticket")))); err != nil { + return err + } + if _, err := w.Write([]byte("Ticket")); err != nil { + return err + } + + if err := t.Ticket.MarshalCBOR(w); err != nil { + return err + } + + // t.PreCommit1Out (storage.PreCommit1Out) (slice) + if len("PreCommit1Out") > cbg.MaxLength { + return xerrors.Errorf("Value in field \"PreCommit1Out\" was too long") + } + + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("PreCommit1Out")))); err != nil { + return err + } + if _, err := w.Write([]byte("PreCommit1Out")); err != nil { + return err + } + + if len(t.PreCommit1Out) > cbg.ByteArrayMaxLen { + return xerrors.Errorf("Byte array in field t.PreCommit1Out was too long") + } + + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.PreCommit1Out)))); err != nil { + return err + } + if _, err := w.Write(t.PreCommit1Out); err != nil { + return err + } + // t.CommD (cid.Cid) (struct) if len("CommD") > cbg.MaxLength { return xerrors.Errorf("Value in field \"CommD\" was too long") @@ -351,22 +390,6 @@ func (t *SectorInfo) MarshalCBOR(w io.Writer) error { return err } - // t.Ticket (api.SealTicket) (struct) - if len("Ticket") > cbg.MaxLength { - return xerrors.Errorf("Value in field \"Ticket\" was too long") - } - - if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Ticket")))); err != nil { - return err - } - if _, err := w.Write([]byte("Ticket")); err != nil { - return err - } - - if err := t.Ticket.MarshalCBOR(w); err != nil { - return err - } - // t.PreCommitMessage (cid.Cid) (struct) if len("PreCommitMessage") > cbg.MaxLength { return xerrors.Errorf("Value in field \"PreCommitMessage\" was too long") @@ -624,6 +647,34 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error { t.Pieces[i] = v } + // t.Ticket (api.SealTicket) (struct) + case "Ticket": + + { + + if err := t.Ticket.UnmarshalCBOR(br); err != nil { + return xerrors.Errorf("unmarshaling t.Ticket: %w", err) + } + + } + // t.PreCommit1Out (storage.PreCommit1Out) (slice) + case "PreCommit1Out": + + maj, extra, err = cbg.CborReadHeader(br) + if err != nil { + return err + } + + if extra > cbg.ByteArrayMaxLen { + return fmt.Errorf("t.PreCommit1Out: byte array too large (%d)", extra) + } + if maj != cbg.MajByteString { + return fmt.Errorf("expected byte array") + } + t.PreCommit1Out = make([]byte, extra) + if _, err := io.ReadFull(br, t.PreCommit1Out); err != nil { + return err + } // t.CommD (cid.Cid) (struct) case "CommD": @@ -692,16 +743,6 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.Proof); err != nil { return err } - // t.Ticket (api.SealTicket) (struct) - case "Ticket": - - { - - if err := t.Ticket.UnmarshalCBOR(br); err != nil { - return xerrors.Errorf("unmarshaling t.Ticket: %w", err) - } - - } // t.PreCommitMessage (cid.Cid) (struct) case "PreCommitMessage":