2019-11-05 03:42:13 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
|
|
cbg "github.com/whyrusleeping/cbor-gen"
|
|
|
|
xerrors "golang.org/x/xerrors"
|
|
|
|
)
|
|
|
|
|
2019-12-12 23:00:20 +00:00
|
|
|
// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
|
2019-11-05 03:42:13 +00:00
|
|
|
|
|
|
|
var _ = xerrors.Errorf
|
|
|
|
|
|
|
|
func (t *PaymentInfo) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
if _, err := w.Write([]byte{163}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Channel (address.Address) (struct)
|
2020-01-08 19:24:44 +00:00
|
|
|
if len("Channel") > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Value in field \"Channel\" was too long")
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Channel")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("Channel")); err != nil {
|
2019-11-05 03:42:13 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := t.Channel.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.ChannelMessage (cid.Cid) (struct)
|
2020-01-08 19:24:44 +00:00
|
|
|
if len("ChannelMessage") > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Value in field \"ChannelMessage\" was too long")
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("ChannelMessage")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("ChannelMessage")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
|
|
|
|
if t.ChannelMessage == nil {
|
|
|
|
if _, err := w.Write(cbg.CborNull); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if err := cbg.WriteCid(w, *t.ChannelMessage); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.ChannelMessage: %w", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Vouchers ([]*types.SignedVoucher) (slice)
|
2020-01-08 19:24:44 +00:00
|
|
|
if len("Vouchers") > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Value in field \"Vouchers\" was too long")
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Vouchers")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("Vouchers")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-01-08 19:24:44 +00:00
|
|
|
if len(t.Vouchers) > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Slice value in field t.Vouchers was too long")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Vouchers)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, v := range t.Vouchers {
|
|
|
|
if err := v.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
if maj != cbg.MajMap {
|
|
|
|
return fmt.Errorf("cbor input should be of type map")
|
2019-11-05 03:42:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 3 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
var name string
|
|
|
|
|
|
|
|
// t.Channel (address.Address) (struct)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "Channel" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be Channel", name)
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Channel.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.ChannelMessage (cid.Cid) (struct)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "ChannelMessage" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be ChannelMessage", name)
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
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.ChannelMessage: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.ChannelMessage = &c
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Vouchers ([]*types.SignedVoucher) (slice)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "Vouchers" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be Vouchers", name)
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
|
|
|
|
if extra > cbg.MaxLength {
|
2019-11-05 03:42:13 +00:00
|
|
|
return fmt.Errorf("t.Vouchers: array too large (%d)", extra)
|
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("expected cbor array")
|
|
|
|
}
|
|
|
|
if extra > 0 {
|
|
|
|
t.Vouchers = make([]*types.SignedVoucher, extra)
|
|
|
|
}
|
|
|
|
for i := 0; i < int(extra); i++ {
|
|
|
|
|
|
|
|
var v types.SignedVoucher
|
|
|
|
if err := v.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Vouchers[i] = &v
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2019-11-06 12:22:08 +00:00
|
|
|
|
|
|
|
func (t *SealedRef) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
if _, err := w.Write([]byte{163}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.SectorID (uint64) (uint64)
|
2020-01-08 19:24:44 +00:00
|
|
|
if len("SectorID") > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Value in field \"SectorID\" was too long")
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("SectorID")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("SectorID")); err != nil {
|
2019-11-06 12:22:08 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-01 17:58:31 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorID))); err != nil {
|
2019-11-06 12:22:08 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Offset (uint64) (uint64)
|
2020-01-08 19:24:44 +00:00
|
|
|
if len("Offset") > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Value in field \"Offset\" was too long")
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Offset")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("Offset")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-06 12:22:08 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Offset))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Size (uint64) (uint64)
|
2020-01-08 19:24:44 +00:00
|
|
|
if len("Size") > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Value in field \"Size\" was too long")
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Size")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("Size")); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-06 12:22:08 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Size))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *SealedRef) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
if maj != cbg.MajMap {
|
|
|
|
return fmt.Errorf("cbor input should be of type map")
|
2019-11-06 12:22:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 3 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
var name string
|
|
|
|
|
|
|
|
// t.SectorID (uint64) (uint64)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "SectorID" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be SectorID", name)
|
|
|
|
}
|
2019-11-06 12:22:08 +00:00
|
|
|
|
2019-12-01 17:58:31 +00:00
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
2019-11-06 12:22:08 +00:00
|
|
|
}
|
2019-12-01 17:58:31 +00:00
|
|
|
t.SectorID = uint64(extra)
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Offset (uint64) (uint64)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "Offset" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be Offset", name)
|
|
|
|
}
|
2019-11-06 12:22:08 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if maj != cbg.MajUnsignedInt {
|
|
|
|
return fmt.Errorf("wrong type for uint64 field")
|
|
|
|
}
|
|
|
|
t.Offset = uint64(extra)
|
2019-12-09 16:40:15 +00:00
|
|
|
// t.Size (uint64) (uint64)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "Size" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be Size", name)
|
|
|
|
}
|
2019-11-06 12:22:08 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *SealedRefs) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
if _, err := w.Write([]byte{161}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Refs ([]api.SealedRef) (slice)
|
2020-01-08 19:24:44 +00:00
|
|
|
if len("Refs") > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Value in field \"Refs\" was too long")
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Refs")))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte("Refs")); err != nil {
|
2019-11-06 12:22:08 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-01-08 19:24:44 +00:00
|
|
|
if len(t.Refs) > cbg.MaxLength {
|
|
|
|
return xerrors.Errorf("Slice value in field t.Refs was too long")
|
|
|
|
}
|
|
|
|
|
2019-11-06 12:22:08 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Refs)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, v := range t.Refs {
|
|
|
|
if err := v.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *SealedRefs) UnmarshalCBOR(r io.Reader) error {
|
|
|
|
br := cbg.GetPeeker(r)
|
|
|
|
|
|
|
|
maj, extra, err := cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
if maj != cbg.MajMap {
|
|
|
|
return fmt.Errorf("cbor input should be of type map")
|
2019-11-06 12:22:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if extra != 1 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-12-09 16:40:15 +00:00
|
|
|
var name string
|
|
|
|
|
|
|
|
// t.Refs ([]api.SealedRef) (slice)
|
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
name = string(sval)
|
|
|
|
}
|
|
|
|
|
|
|
|
if name != "Refs" {
|
|
|
|
return fmt.Errorf("expected struct map entry %s to be Refs", name)
|
|
|
|
}
|
2019-11-06 12:22:08 +00:00
|
|
|
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-12-09 16:40:15 +00:00
|
|
|
|
|
|
|
if extra > cbg.MaxLength {
|
2019-11-06 12:22:08 +00:00
|
|
|
return fmt.Errorf("t.Refs: array too large (%d)", extra)
|
|
|
|
}
|
|
|
|
|
|
|
|
if maj != cbg.MajArray {
|
|
|
|
return fmt.Errorf("expected cbor array")
|
|
|
|
}
|
|
|
|
if extra > 0 {
|
|
|
|
t.Refs = make([]SealedRef, extra)
|
|
|
|
}
|
|
|
|
for i := 0; i < int(extra); i++ {
|
|
|
|
|
|
|
|
var v SealedRef
|
|
|
|
if err := v.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Refs[i] = v
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|