github.com/filecoin-project/specs-actors/v4@v4.0.2/actors/builtin/verifreg/cbor_gen.go (about) 1 // Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. 2 3 package verifreg 4 5 import ( 6 "fmt" 7 "io" 8 9 cbg "github.com/whyrusleeping/cbor-gen" 10 xerrors "golang.org/x/xerrors" 11 ) 12 13 var _ = xerrors.Errorf 14 15 var lengthBufState = []byte{131} 16 17 func (t *State) MarshalCBOR(w io.Writer) error { 18 if t == nil { 19 _, err := w.Write(cbg.CborNull) 20 return err 21 } 22 if _, err := w.Write(lengthBufState); err != nil { 23 return err 24 } 25 26 scratch := make([]byte, 9) 27 28 // t.RootKey (address.Address) (struct) 29 if err := t.RootKey.MarshalCBOR(w); err != nil { 30 return err 31 } 32 33 // t.Verifiers (cid.Cid) (struct) 34 35 if err := cbg.WriteCidBuf(scratch, w, t.Verifiers); err != nil { 36 return xerrors.Errorf("failed to write cid field t.Verifiers: %w", err) 37 } 38 39 // t.VerifiedClients (cid.Cid) (struct) 40 41 if err := cbg.WriteCidBuf(scratch, w, t.VerifiedClients); err != nil { 42 return xerrors.Errorf("failed to write cid field t.VerifiedClients: %w", err) 43 } 44 45 return nil 46 } 47 48 func (t *State) UnmarshalCBOR(r io.Reader) error { 49 *t = State{} 50 51 br := cbg.GetPeeker(r) 52 scratch := make([]byte, 8) 53 54 maj, extra, err := cbg.CborReadHeaderBuf(br, scratch) 55 if err != nil { 56 return err 57 } 58 if maj != cbg.MajArray { 59 return fmt.Errorf("cbor input should be of type array") 60 } 61 62 if extra != 3 { 63 return fmt.Errorf("cbor input had wrong number of fields") 64 } 65 66 // t.RootKey (address.Address) (struct) 67 68 { 69 70 if err := t.RootKey.UnmarshalCBOR(br); err != nil { 71 return xerrors.Errorf("unmarshaling t.RootKey: %w", err) 72 } 73 74 } 75 // t.Verifiers (cid.Cid) (struct) 76 77 { 78 79 c, err := cbg.ReadCid(br) 80 if err != nil { 81 return xerrors.Errorf("failed to read cid field t.Verifiers: %w", err) 82 } 83 84 t.Verifiers = c 85 86 } 87 // t.VerifiedClients (cid.Cid) (struct) 88 89 { 90 91 c, err := cbg.ReadCid(br) 92 if err != nil { 93 return xerrors.Errorf("failed to read cid field t.VerifiedClients: %w", err) 94 } 95 96 t.VerifiedClients = c 97 98 } 99 return nil 100 }