2019-10-22 10:20:43 +00:00
|
|
|
package deals
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
|
2019-10-23 12:59:57 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/actors"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
2019-10-22 10:20:43 +00:00
|
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
|
|
|
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 *AskRequest) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte{129}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Miner (address.Address) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
if err := t.Miner.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *AskRequest) 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 != 1 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Miner (address.Address) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Miner.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *AskResponse) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte{129}); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Ask (types.SignedStorageAsk) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
if err := t.Ask.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *AskResponse) 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 != 1 {
|
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Ask (types.SignedStorageAsk) (struct)
|
2019-10-22 10:20:43 +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 {
|
|
|
|
t.Ask = new(types.SignedStorageAsk)
|
|
|
|
if err := t.Ask.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *Proposal) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-11-06 17:38:42 +00:00
|
|
|
if _, err := w.Write([]byte{130}); err != nil {
|
2019-10-22 10:20:43 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.DealProposal (actors.StorageDealProposal) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
if err := t.DealProposal.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-11-06 17:38:42 +00:00
|
|
|
|
|
|
|
// t.t.Piece (cid.Cid) (struct)
|
|
|
|
|
|
|
|
if err := cbg.WriteCid(w, t.Piece); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.Piece: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-10-22 10:20:43 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *Proposal) 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")
|
|
|
|
}
|
|
|
|
|
2019-11-06 17:38:42 +00:00
|
|
|
if extra != 2 {
|
2019-10-22 10:20:43 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.DealProposal (actors.StorageDealProposal) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
2019-11-06 17:38:42 +00:00
|
|
|
pb, err := br.PeekByte()
|
|
|
|
if err != nil {
|
2019-10-22 10:20:43 +00:00
|
|
|
return err
|
|
|
|
}
|
2019-11-06 17:38:42 +00:00
|
|
|
if pb == cbg.CborNull[0] {
|
|
|
|
var nbuf [1]byte
|
|
|
|
if _, err := br.Read(nbuf[:]); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
t.DealProposal = new(actors.StorageDealProposal)
|
|
|
|
if err := t.DealProposal.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
// t.t.Piece (cid.Cid) (struct)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.Piece: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Piece = c
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *Response) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-11-07 12:57:00 +00:00
|
|
|
if _, err := w.Write([]byte{133}); err != nil {
|
2019-10-22 10:20:43 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.State (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.State))); err != nil {
|
2019-10-22 10:20:43 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Message (string) (string)
|
2019-10-22 10:20:43 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.Message)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte(t.Message)); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Proposal (cid.Cid) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
if err := cbg.WriteCid(w, t.Proposal); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.Proposal: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.StorageDeal (actors.StorageDeal) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
if err := t.StorageDeal.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.PublishMessage (cid.Cid) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
2019-10-23 12:59:57 +00:00
|
|
|
if t.PublishMessage == nil {
|
|
|
|
if _, err := w.Write(cbg.CborNull); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if err := cbg.WriteCid(w, *t.PublishMessage); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.PublishMessage: %w", err)
|
|
|
|
}
|
2019-10-22 10:20:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *Response) 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")
|
|
|
|
}
|
|
|
|
|
2019-11-07 12:57:00 +00:00
|
|
|
if extra != 5 {
|
2019-10-22 10:20:43 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.State (uint64) (uint64)
|
2019-10-22 10:20:43 +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-05 03:42:13 +00:00
|
|
|
t.State = uint64(extra)
|
|
|
|
// t.t.Message (string) (string)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Message = string(sval)
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Proposal (cid.Cid) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.Proposal: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Proposal = c
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.StorageDeal (actors.StorageDeal) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
2019-10-23 12:59:57 +00:00
|
|
|
pb, err := br.PeekByte()
|
|
|
|
if err != nil {
|
2019-10-22 10:20:43 +00:00
|
|
|
return err
|
|
|
|
}
|
2019-10-23 12:59:57 +00:00
|
|
|
if pb == cbg.CborNull[0] {
|
|
|
|
var nbuf [1]byte
|
|
|
|
if _, err := br.Read(nbuf[:]); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
t.StorageDeal = new(actors.StorageDeal)
|
|
|
|
if err := t.StorageDeal.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.PublishMessage (cid.Cid) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
2019-10-23 12:59:57 +00:00
|
|
|
pb, err := br.PeekByte()
|
2019-10-22 10:20:43 +00:00
|
|
|
if err != nil {
|
2019-10-23 12:59:57 +00:00
|
|
|
return err
|
2019-10-22 10:20:43 +00:00
|
|
|
}
|
2019-10-23 12:59:57 +00:00
|
|
|
if pb == cbg.CborNull[0] {
|
|
|
|
var nbuf [1]byte
|
|
|
|
if _, err := br.Read(nbuf[:]); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
2019-10-22 10:20:43 +00:00
|
|
|
|
2019-10-23 12:59:57 +00:00
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.PublishMessage: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.PublishMessage = &c
|
|
|
|
}
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *SignedResponse) 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
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Response (deals.Response) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
if err := t.Response.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Signature (types.Signature) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
if err := t.Signature.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *SignedResponse) 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")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Response (deals.Response) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Response.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Signature (types.Signature) (struct)
|
2019-10-22 10:20:43 +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 {
|
|
|
|
t.Signature = new(types.Signature)
|
|
|
|
if err := t.Signature.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *ClientDealProposal) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-11-07 14:09:11 +00:00
|
|
|
if _, err := w.Write([]byte{136}); err != nil {
|
2019-10-22 10:20:43 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Data (cid.Cid) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
if err := cbg.WriteCid(w, t.Data); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.Data: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.PricePerEpoch (types.BigInt) (struct)
|
2019-10-29 10:01:18 +00:00
|
|
|
if err := t.PricePerEpoch.MarshalCBOR(w); err != nil {
|
2019-10-22 10:20:43 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ProposalExpiration (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.ProposalExpiration))); err != nil {
|
2019-10-22 10:20:43 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Duration (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Duration))); err != nil {
|
2019-10-22 10:20:43 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ProviderAddress (address.Address) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
if err := t.ProviderAddress.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Client (address.Address) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
if err := t.Client.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-07 14:09:11 +00:00
|
|
|
// t.t.MinerWorker (address.Address) (struct)
|
|
|
|
if err := t.MinerWorker.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.MinerID (peer.ID) (string)
|
2019-10-22 10:20:43 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.MinerID)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte(t.MinerID)); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *ClientDealProposal) 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")
|
|
|
|
}
|
|
|
|
|
2019-11-07 14:09:11 +00:00
|
|
|
if extra != 8 {
|
2019-10-22 10:20:43 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Data (cid.Cid) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.Data: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Data = c
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.PricePerEpoch (types.BigInt) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
2019-10-29 10:01:18 +00:00
|
|
|
if err := t.PricePerEpoch.UnmarshalCBOR(br); err != nil {
|
2019-10-22 10:20:43 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ProposalExpiration (uint64) (uint64)
|
2019-10-22 10:20:43 +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-05 03:42:13 +00:00
|
|
|
t.ProposalExpiration = uint64(extra)
|
|
|
|
// t.t.Duration (uint64) (uint64)
|
2019-10-22 10:20:43 +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-05 03:42:13 +00:00
|
|
|
t.Duration = uint64(extra)
|
|
|
|
// t.t.ProviderAddress (address.Address) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.ProviderAddress.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Client (address.Address) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Client.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-07 14:09:11 +00:00
|
|
|
}
|
|
|
|
// t.t.MinerWorker (address.Address) (struct)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.MinerWorker.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-10-22 10:20:43 +00:00
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.MinerID (peer.ID) (string)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.MinerID = peer.ID(sval)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *ClientDeal) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-11-07 14:09:11 +00:00
|
|
|
if _, err := w.Write([]byte{135}); err != nil {
|
2019-10-22 10:20:43 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ProposalCid (cid.Cid) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
if err := cbg.WriteCid(w, t.ProposalCid); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.ProposalCid: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Proposal (actors.StorageDealProposal) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
if err := t.Proposal.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.State (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.State))); err != nil {
|
2019-10-22 10:20:43 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Miner (peer.ID) (string)
|
2019-10-22 10:20:43 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.Miner)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte(t.Miner)); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-11-07 12:03:18 +00:00
|
|
|
|
2019-11-07 14:09:11 +00:00
|
|
|
// t.t.MinerWorker (address.Address) (struct)
|
|
|
|
if err := t.MinerWorker.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-07 12:03:18 +00:00
|
|
|
// t.t.DealID (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.DealID))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-11-07 13:29:43 +00:00
|
|
|
|
|
|
|
// t.t.PublishMessage (cid.Cid) (struct)
|
|
|
|
|
|
|
|
if t.PublishMessage == nil {
|
|
|
|
if _, err := w.Write(cbg.CborNull); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if err := cbg.WriteCid(w, *t.PublishMessage); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.PublishMessage: %w", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-22 10:20:43 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *ClientDeal) 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")
|
|
|
|
}
|
|
|
|
|
2019-11-07 14:09:11 +00:00
|
|
|
if extra != 7 {
|
2019-10-22 10:20:43 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ProposalCid (cid.Cid) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.ProposalCid: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.ProposalCid = c
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Proposal (actors.StorageDealProposal) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Proposal.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.State (uint64) (uint64)
|
2019-10-22 10:20:43 +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-05 03:42:13 +00:00
|
|
|
t.State = uint64(extra)
|
|
|
|
// t.t.Miner (peer.ID) (string)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Miner = peer.ID(sval)
|
|
|
|
}
|
2019-11-07 14:09:11 +00:00
|
|
|
// t.t.MinerWorker (address.Address) (struct)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.MinerWorker.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-07 12:03:18 +00:00
|
|
|
// 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)
|
2019-11-07 13:29:43 +00:00
|
|
|
// t.t.PublishMessage (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.PublishMessage: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.PublishMessage = &c
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-10-22 10:20:43 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MinerDeal) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-10-24 14:24:31 +00:00
|
|
|
if _, err := w.Write([]byte{135}); err != nil {
|
2019-10-22 10:20:43 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Client (peer.ID) (string)
|
2019-10-22 10:20:43 +00:00
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.Client)))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if _, err := w.Write([]byte(t.Client)); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Proposal (actors.StorageDealProposal) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
if err := t.Proposal.MarshalCBOR(w); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ProposalCid (cid.Cid) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
if err := cbg.WriteCid(w, t.ProposalCid); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.ProposalCid: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.State (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.State))); err != nil {
|
2019-10-22 10:20:43 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Ref (cid.Cid) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
if err := cbg.WriteCid(w, t.Ref); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.Ref: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.DealID (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.DealID))); err != nil {
|
2019-10-24 14:24:31 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.SectorID (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorID))); err != nil {
|
2019-10-22 10:20:43 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MinerDeal) 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")
|
|
|
|
}
|
|
|
|
|
2019-10-24 14:24:31 +00:00
|
|
|
if extra != 7 {
|
2019-10-22 10:20:43 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Client (peer.ID) (string)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
sval, err := cbg.ReadString(br)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Client = peer.ID(sval)
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.Proposal (actors.StorageDealProposal) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if err := t.Proposal.UnmarshalCBOR(br); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.ProposalCid (cid.Cid) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.ProposalCid: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.ProposalCid = c
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.State (uint64) (uint64)
|
2019-10-22 10:20:43 +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-05 03:42:13 +00:00
|
|
|
t.State = uint64(extra)
|
|
|
|
// t.t.Ref (cid.Cid) (struct)
|
2019-10-22 10:20:43 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.Ref: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Ref = c
|
|
|
|
|
|
|
|
}
|
2019-11-05 03:42:13 +00:00
|
|
|
// t.t.DealID (uint64) (uint64)
|
2019-10-24 14:24: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-05 03:42:13 +00:00
|
|
|
t.DealID = uint64(extra)
|
|
|
|
// t.t.SectorID (uint64) (uint64)
|
2019-10-22 10:20:43 +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-05 03:42:13 +00:00
|
|
|
t.SectorID = uint64(extra)
|
2019-10-22 10:20:43 +00:00
|
|
|
return nil
|
|
|
|
}
|
2019-10-31 03:00:02 +00:00
|
|
|
|
|
|
|
func (t *StorageDataTransferVoucher) MarshalCBOR(w io.Writer) error {
|
|
|
|
if t == nil {
|
|
|
|
_, err := w.Write(cbg.CborNull)
|
|
|
|
return err
|
|
|
|
}
|
2019-12-01 20:07:42 +00:00
|
|
|
if _, err := w.Write([]byte{130}); err != nil {
|
2019-10-31 03:00:02 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-13 23:04:13 +00:00
|
|
|
// t.t.Proposal (cid.Cid) (struct)
|
2019-10-31 03:00:02 +00:00
|
|
|
|
|
|
|
if err := cbg.WriteCid(w, t.Proposal); err != nil {
|
|
|
|
return xerrors.Errorf("failed to write cid field t.Proposal: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-12-01 20:07:42 +00:00
|
|
|
// t.t.DealID (uint64) (uint64)
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.DealID))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2019-10-31 03:00:02 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *StorageDataTransferVoucher) 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")
|
|
|
|
}
|
|
|
|
|
2019-12-01 20:07:42 +00:00
|
|
|
if extra != 2 {
|
2019-10-31 03:00:02 +00:00
|
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
|
|
}
|
|
|
|
|
2019-11-13 23:04:13 +00:00
|
|
|
// t.t.Proposal (cid.Cid) (struct)
|
2019-10-31 03:00:02 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
c, err := cbg.ReadCid(br)
|
|
|
|
if err != nil {
|
|
|
|
return xerrors.Errorf("failed to read cid field t.Proposal: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Proposal = c
|
|
|
|
|
|
|
|
}
|
2019-12-01 20:07:42 +00:00
|
|
|
// 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)
|
2019-10-31 03:00:02 +00:00
|
|
|
return nil
|
|
|
|
}
|