lotus/paychmgr/cbor_gen.go

404 lines
8.6 KiB
Go
Raw Normal View History

// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
package paychmgr
2019-11-04 19:03:11 +00:00
import (
"fmt"
"io"
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
2019-11-04 19:03:11 +00:00
cbg "github.com/whyrusleeping/cbor-gen"
xerrors "golang.org/x/xerrors"
)
var _ = xerrors.Errorf
func (t *VoucherInfo) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
2020-02-13 00:10:07 +00:00
if _, err := w.Write([]byte{162}); err != nil {
2019-11-04 19:03:11 +00:00
return err
}
2020-05-04 22:19:48 +00:00
scratch := make([]byte, 9)
2020-02-12 23:52:19 +00:00
// t.Voucher (paych.SignedVoucher) (struct)
2020-02-13 00:10:07 +00:00
if len("Voucher") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Voucher\" was too long")
}
2020-05-04 22:19:48 +00:00
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Voucher"))); err != nil {
2020-02-13 00:10:07 +00:00
return err
}
2020-07-30 20:25:18 +00:00
if _, err := io.WriteString(w, string("Voucher")); err != nil {
2020-02-13 00:10:07 +00:00
return err
}
2019-11-04 19:03:11 +00:00
if err := t.Voucher.MarshalCBOR(w); err != nil {
return err
}
2019-12-09 16:40:15 +00:00
// t.Proof ([]uint8) (slice)
2020-02-13 00:10:07 +00:00
if len("Proof") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Proof\" was too long")
}
2020-05-04 22:19:48 +00:00
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Proof"))); err != nil {
2020-02-13 00:10:07 +00:00
return err
}
2020-07-30 20:25:18 +00:00
if _, err := io.WriteString(w, string("Proof")); err != nil {
2020-02-13 00:10:07 +00:00
return err
}
2019-12-16 23:44:14 +00:00
if len(t.Proof) > cbg.ByteArrayMaxLen {
return xerrors.Errorf("Byte array in field t.Proof was too long")
}
2020-05-04 22:19:48 +00:00
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajByteString, uint64(len(t.Proof))); err != nil {
2019-11-04 19:03:11 +00:00
return err
}
2020-05-04 22:19:48 +00:00
2020-07-30 20:25:18 +00:00
if _, err := w.Write(t.Proof[:]); err != nil {
2019-11-04 19:03:11 +00:00
return err
}
return nil
}
func (t *VoucherInfo) UnmarshalCBOR(r io.Reader) error {
*t = VoucherInfo{}
2019-11-04 19:03:11 +00:00
br := cbg.GetPeeker(r)
2020-05-04 22:19:48 +00:00
scratch := make([]byte, 8)
2019-11-04 19:03:11 +00:00
2020-05-04 22:19:48 +00:00
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
2019-11-04 19:03:11 +00:00
if err != nil {
return err
}
2020-02-13 00:10:07 +00:00
if maj != cbg.MajMap {
return fmt.Errorf("cbor input should be of type map")
2019-11-04 19:03:11 +00:00
}
2020-02-13 00:10:07 +00:00
if extra > cbg.MaxLength {
return fmt.Errorf("VoucherInfo: map struct too large (%d)", extra)
2019-11-04 19:03:11 +00:00
}
2020-02-13 00:10:07 +00:00
var name string
n := extra
2019-11-04 19:03:11 +00:00
2020-02-13 00:10:07 +00:00
for i := uint64(0); i < n; i++ {
2019-11-04 19:03:11 +00:00
2020-02-13 00:10:07 +00:00
{
2020-05-04 22:19:48 +00:00
sval, err := cbg.ReadStringBuf(br, scratch)
2020-02-13 00:10:07 +00:00
if err != nil {
2019-11-04 19:03:11 +00:00
return err
}
2020-02-13 00:10:07 +00:00
name = string(sval)
}
switch name {
// t.Voucher (paych.SignedVoucher) (struct)
case "Voucher":
{
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 {
t.Voucher = new(paych.SignedVoucher)
2020-02-13 00:10:07 +00:00
if err := t.Voucher.UnmarshalCBOR(br); err != nil {
2020-03-21 21:17:01 +00:00
return xerrors.Errorf("unmarshaling t.Voucher pointer: %w", err)
2020-02-13 00:10:07 +00:00
}
}
}
// t.Proof ([]uint8) (slice)
case "Proof":
2020-05-04 22:19:48 +00:00
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
2020-02-13 00:10:07 +00:00
if err != nil {
2019-11-04 19:03:11 +00:00
return err
}
2020-02-13 00:10:07 +00:00
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")
}
2020-07-30 20:25:18 +00:00
if extra > 0 {
t.Proof = make([]uint8, extra)
}
if _, err := io.ReadFull(br, t.Proof[:]); err != nil {
2020-02-13 00:10:07 +00:00
return err
}
2019-11-04 19:03:11 +00:00
2020-02-13 00:10:07 +00:00
default:
return fmt.Errorf("unknown struct field %d: '%s'", i, name)
}
2019-11-04 19:03:11 +00:00
}
return nil
}
func (t *ChannelInfo) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
}
2020-02-13 00:10:07 +00:00
if _, err := w.Write([]byte{166}); err != nil {
2019-11-04 19:03:11 +00:00
return err
}
2020-05-04 22:19:48 +00:00
scratch := make([]byte, 9)
2019-12-09 16:40:15 +00:00
// t.Channel (address.Address) (struct)
2020-02-13 00:10:07 +00:00
if len("Channel") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Channel\" was too long")
}
2020-05-04 22:19:48 +00:00
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Channel"))); err != nil {
2020-02-13 00:10:07 +00:00
return err
}
2020-07-30 20:25:18 +00:00
if _, err := io.WriteString(w, string("Channel")); err != nil {
2020-02-13 00:10:07 +00:00
return err
}
2019-11-04 19:03:11 +00:00
if err := t.Channel.MarshalCBOR(w); err != nil {
return err
}
2019-12-09 16:40:15 +00:00
// t.Control (address.Address) (struct)
2020-02-13 00:10:07 +00:00
if len("Control") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Control\" was too long")
}
2020-05-04 22:19:48 +00:00
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Control"))); err != nil {
2020-02-13 00:10:07 +00:00
return err
}
2020-07-30 20:25:18 +00:00
if _, err := io.WriteString(w, string("Control")); err != nil {
2020-02-13 00:10:07 +00:00
return err
}
2019-11-04 19:03:11 +00:00
if err := t.Control.MarshalCBOR(w); err != nil {
return err
}
2019-12-09 16:40:15 +00:00
// t.Target (address.Address) (struct)
2020-02-13 00:10:07 +00:00
if len("Target") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Target\" was too long")
}
2020-05-04 22:19:48 +00:00
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Target"))); err != nil {
2020-02-13 00:10:07 +00:00
return err
}
2020-07-30 20:25:18 +00:00
if _, err := io.WriteString(w, string("Target")); err != nil {
2020-02-13 00:10:07 +00:00
return err
}
2019-11-04 19:03:11 +00:00
if err := t.Target.MarshalCBOR(w); err != nil {
return err
}
2019-12-09 16:40:15 +00:00
// t.Direction (uint64) (uint64)
2020-02-13 00:10:07 +00:00
if len("Direction") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Direction\" was too long")
}
2020-05-04 22:19:48 +00:00
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Direction"))); err != nil {
2020-02-13 00:10:07 +00:00
return err
}
2020-07-30 20:25:18 +00:00
if _, err := io.WriteString(w, string("Direction")); err != nil {
2020-02-13 00:10:07 +00:00
return err
}
2020-05-04 22:19:48 +00:00
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Direction)); err != nil {
2019-11-04 19:03:11 +00:00
return err
}
// t.Vouchers ([]*paychmgr.VoucherInfo) (slice)
2020-02-13 00:10:07 +00:00
if len("Vouchers") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Vouchers\" was too long")
}
2020-05-04 22:19:48 +00:00
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Vouchers"))); err != nil {
2020-02-13 00:10:07 +00:00
return err
}
2020-07-30 20:25:18 +00:00
if _, err := io.WriteString(w, string("Vouchers")); err != nil {
2020-02-13 00:10:07 +00:00
return err
}
2019-12-16 23:44:14 +00:00
if len(t.Vouchers) > cbg.MaxLength {
return xerrors.Errorf("Slice value in field t.Vouchers was too long")
}
2020-05-04 22:19:48 +00:00
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Vouchers))); err != nil {
2019-11-04 19:03:11 +00:00
return err
}
for _, v := range t.Vouchers {
if err := v.MarshalCBOR(w); err != nil {
return err
}
}
2019-12-09 16:40:15 +00:00
// t.NextLane (uint64) (uint64)
2020-02-13 00:10:07 +00:00
if len("NextLane") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"NextLane\" was too long")
}
2020-05-04 22:19:48 +00:00
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("NextLane"))); err != nil {
2020-02-13 00:10:07 +00:00
return err
}
2020-07-30 20:25:18 +00:00
if _, err := io.WriteString(w, string("NextLane")); err != nil {
2020-02-13 00:10:07 +00:00
return err
}
2020-05-04 22:19:48 +00:00
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.NextLane)); err != nil {
2019-11-04 19:03:11 +00:00
return err
}
2020-02-23 00:47:47 +00:00
2019-11-04 19:03:11 +00:00
return nil
}
func (t *ChannelInfo) UnmarshalCBOR(r io.Reader) error {
*t = ChannelInfo{}
2019-11-04 19:03:11 +00:00
br := cbg.GetPeeker(r)
2020-05-04 22:19:48 +00:00
scratch := make([]byte, 8)
2019-11-04 19:03:11 +00:00
2020-05-04 22:19:48 +00:00
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
2019-11-04 19:03:11 +00:00
if err != nil {
return err
}
2020-02-13 00:10:07 +00:00
if maj != cbg.MajMap {
return fmt.Errorf("cbor input should be of type map")
2019-11-04 19:03:11 +00:00
}
2020-02-13 00:10:07 +00:00
if extra > cbg.MaxLength {
return fmt.Errorf("ChannelInfo: map struct too large (%d)", extra)
2019-11-04 19:03:11 +00:00
}
2020-02-13 00:10:07 +00:00
var name string
n := extra
2019-11-04 19:03:11 +00:00
2020-02-13 00:10:07 +00:00
for i := uint64(0); i < n; i++ {
2019-11-04 19:03:11 +00:00
2020-02-13 00:10:07 +00:00
{
2020-05-04 22:19:48 +00:00
sval, err := cbg.ReadStringBuf(br, scratch)
2020-02-13 00:10:07 +00:00
if err != nil {
return err
}
name = string(sval)
2019-11-04 19:03:11 +00:00
}
2020-02-13 00:10:07 +00:00
switch name {
// t.Channel (address.Address) (struct)
case "Channel":
2019-11-04 19:03:11 +00:00
2020-02-13 00:10:07 +00:00
{
2019-11-04 19:03:11 +00:00
2020-02-13 00:10:07 +00:00
if err := t.Channel.UnmarshalCBOR(br); err != nil {
2020-03-21 21:17:01 +00:00
return xerrors.Errorf("unmarshaling t.Channel: %w", err)
2020-02-13 00:10:07 +00:00
}
2019-11-04 19:03:11 +00:00
2020-02-13 00:10:07 +00:00
}
// t.Control (address.Address) (struct)
case "Control":
2019-11-04 19:03:11 +00:00
2020-02-13 00:10:07 +00:00
{
2019-11-04 19:03:11 +00:00
2020-02-13 00:10:07 +00:00
if err := t.Control.UnmarshalCBOR(br); err != nil {
2020-03-21 21:17:01 +00:00
return xerrors.Errorf("unmarshaling t.Control: %w", err)
2020-02-13 00:10:07 +00:00
}
2019-11-04 19:03:11 +00:00
2020-02-13 00:10:07 +00:00
}
// t.Target (address.Address) (struct)
case "Target":
2019-11-04 19:03:11 +00:00
2020-02-13 00:10:07 +00:00
{
2019-11-04 19:03:11 +00:00
2020-02-13 00:10:07 +00:00
if err := t.Target.UnmarshalCBOR(br); err != nil {
2020-03-21 21:17:01 +00:00
return xerrors.Errorf("unmarshaling t.Target: %w", err)
2020-02-13 00:10:07 +00:00
}
2019-12-09 16:40:15 +00:00
2020-02-13 00:10:07 +00:00
}
// t.Direction (uint64) (uint64)
case "Direction":
2019-11-04 19:03:11 +00:00
2020-02-23 00:47:47 +00:00
{
2020-05-04 22:19:48 +00:00
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
2020-02-23 00:47:47 +00:00
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.Direction = uint64(extra)
2020-02-13 00:10:07 +00:00
}
// t.Vouchers ([]*paychmgr.VoucherInfo) (slice)
2020-02-13 00:10:07 +00:00
case "Vouchers":
2019-11-04 19:03:11 +00:00
2020-05-04 22:19:48 +00:00
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
2020-02-13 00:10:07 +00:00
if err != nil {
return err
}
2019-11-04 19:03:11 +00:00
2020-02-13 00:10:07 +00:00
if extra > cbg.MaxLength {
return fmt.Errorf("t.Vouchers: array too large (%d)", extra)
}
2019-11-04 19:03:11 +00:00
2020-02-13 00:10:07 +00:00
if maj != cbg.MajArray {
return fmt.Errorf("expected cbor array")
}
2020-04-17 17:53:09 +00:00
2020-02-13 00:10:07 +00:00
if extra > 0 {
t.Vouchers = make([]*VoucherInfo, extra)
}
2020-04-17 17:53:09 +00:00
2020-02-13 00:10:07 +00:00
for i := 0; i < int(extra); i++ {
2019-11-04 19:03:11 +00:00
2020-02-13 00:10:07 +00:00
var v VoucherInfo
if err := v.UnmarshalCBOR(br); err != nil {
return err
}
t.Vouchers[i] = &v
}
// t.NextLane (uint64) (uint64)
case "NextLane":
2020-02-23 00:47:47 +00:00
{
2020-05-04 22:19:48 +00:00
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
2020-02-23 00:47:47 +00:00
if err != nil {
return err
}
if maj != cbg.MajUnsignedInt {
return fmt.Errorf("wrong type for uint64 field")
}
t.NextLane = uint64(extra)
2020-02-13 00:10:07 +00:00
}
default:
return fmt.Errorf("unknown struct field %d: '%s'", i, name)
}
2019-11-04 19:03:11 +00:00
}
2020-02-13 00:10:07 +00:00
2019-11-04 19:03:11 +00:00
return nil
}