Types for storage market Modify deals.Provider to implement storagemarket.StorageProvider Inject storagemarket.StorageProvider Storage Provider interfaces Storage Client interfaces Add ValidatePublishedDeal to ClientNodeAdapter Remove FundManager from client Remove Wallet from client Remove StateManager, Events, Wallet from client Rebasing - Copy types.BigInt, use TokenAmount/BigInt for token amounts - Remove auto-imported log package - Move `checkAskSignature` to a client file. - Plumb contexts through fix(storagemarket): use publish cids Switch back to publish message cids to reduce the dependency surface area
477 lines
9.4 KiB
Go
477 lines
9.4 KiB
Go
package retrievalimpl
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
|
|
cbg "github.com/whyrusleeping/cbor-gen"
|
|
xerrors "golang.org/x/xerrors"
|
|
)
|
|
|
|
// Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT.
|
|
|
|
var _ = xerrors.Errorf
|
|
|
|
func (t *RetParams) 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
|
|
}
|
|
|
|
// t.Unixfs0 (retrievalimpl.Unixfs0Offer) (struct)
|
|
if err := t.Unixfs0.MarshalCBOR(w); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (t *RetParams) 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")
|
|
}
|
|
|
|
// t.Unixfs0 (retrievalimpl.Unixfs0Offer) (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 {
|
|
t.Unixfs0 = new(Unixfs0Offer)
|
|
if err := t.Unixfs0.UnmarshalCBOR(br); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (t *OldQuery) 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
|
|
}
|
|
|
|
// 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)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (t *OldQuery) 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")
|
|
}
|
|
|
|
// 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
|
|
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (t *OldQueryResponse) MarshalCBOR(w io.Writer) error {
|
|
if t == nil {
|
|
_, err := w.Write(cbg.CborNull)
|
|
return err
|
|
}
|
|
if _, err := w.Write([]byte{131}); err != nil {
|
|
return err
|
|
}
|
|
|
|
// t.Status (retrievalimpl.OldQueryResponseStatus) (uint64)
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Status))); err != nil {
|
|
return err
|
|
}
|
|
|
|
// t.Size (uint64) (uint64)
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Size))); err != nil {
|
|
return err
|
|
}
|
|
|
|
// t.MinPrice (types.BigInt) (struct)
|
|
if err := t.MinPrice.MarshalCBOR(w); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (t *OldQueryResponse) 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 != 3 {
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
}
|
|
|
|
// t.Status (retrievalimpl.OldQueryResponseStatus) (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.Status = OldQueryResponseStatus(extra)
|
|
// t.Size (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.Size = uint64(extra)
|
|
// t.MinPrice (types.BigInt) (struct)
|
|
|
|
{
|
|
|
|
if err := t.MinPrice.UnmarshalCBOR(br); err != nil {
|
|
return err
|
|
}
|
|
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (t *Unixfs0Offer) 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
|
|
}
|
|
|
|
// t.Offset (uint64) (uint64)
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Offset))); err != nil {
|
|
return err
|
|
}
|
|
|
|
// t.Size (uint64) (uint64)
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Size))); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (t *Unixfs0Offer) 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")
|
|
}
|
|
|
|
// t.Offset (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.Offset = uint64(extra)
|
|
// t.Size (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.Size = uint64(extra)
|
|
return nil
|
|
}
|
|
|
|
func (t *OldDealProposal) MarshalCBOR(w io.Writer) error {
|
|
if t == nil {
|
|
_, err := w.Write(cbg.CborNull)
|
|
return err
|
|
}
|
|
if _, err := w.Write([]byte{131}); err != nil {
|
|
return err
|
|
}
|
|
|
|
// t.Payment (api.PaymentInfo) (struct)
|
|
if err := t.Payment.MarshalCBOR(w); err != nil {
|
|
return err
|
|
}
|
|
|
|
// t.Ref (cid.Cid) (struct)
|
|
|
|
if err := cbg.WriteCid(w, t.Ref); err != nil {
|
|
return xerrors.Errorf("failed to write cid field t.Ref: %w", err)
|
|
}
|
|
|
|
// t.Params (retrievalimpl.RetParams) (struct)
|
|
if err := t.Params.MarshalCBOR(w); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (t *OldDealProposal) 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 != 3 {
|
|
return fmt.Errorf("cbor input had wrong number of fields")
|
|
}
|
|
|
|
// t.Payment (api.PaymentInfo) (struct)
|
|
|
|
{
|
|
|
|
if err := t.Payment.UnmarshalCBOR(br); err != nil {
|
|
return err
|
|
}
|
|
|
|
}
|
|
// t.Ref (cid.Cid) (struct)
|
|
|
|
{
|
|
|
|
c, err := cbg.ReadCid(br)
|
|
if err != nil {
|
|
return xerrors.Errorf("failed to read cid field t.Ref: %w", err)
|
|
}
|
|
|
|
t.Ref = c
|
|
|
|
}
|
|
// t.Params (retrievalimpl.RetParams) (struct)
|
|
|
|
{
|
|
|
|
if err := t.Params.UnmarshalCBOR(br); err != nil {
|
|
return err
|
|
}
|
|
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (t *OldDealResponse) 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
|
|
}
|
|
|
|
// t.Status (uint64) (uint64)
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Status))); err != nil {
|
|
return err
|
|
}
|
|
|
|
// t.Message (string) (string)
|
|
if len(t.Message) > cbg.MaxLength {
|
|
return xerrors.Errorf("Value in field t.Message was too long")
|
|
}
|
|
|
|
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
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (t *OldDealResponse) 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")
|
|
}
|
|
|
|
// t.Status (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.Status = uint64(extra)
|
|
// t.Message (string) (string)
|
|
|
|
{
|
|
sval, err := cbg.ReadString(br)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
t.Message = string(sval)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (t *Block) 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
|
|
}
|
|
|
|
// t.Prefix ([]uint8) (slice)
|
|
if len(t.Prefix) > cbg.ByteArrayMaxLen {
|
|
return xerrors.Errorf("Byte array in field t.Prefix was too long")
|
|
}
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Prefix)))); err != nil {
|
|
return err
|
|
}
|
|
if _, err := w.Write(t.Prefix); err != nil {
|
|
return err
|
|
}
|
|
|
|
// t.Data ([]uint8) (slice)
|
|
if len(t.Data) > cbg.ByteArrayMaxLen {
|
|
return xerrors.Errorf("Byte array in field t.Data was too long")
|
|
}
|
|
|
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Data)))); err != nil {
|
|
return err
|
|
}
|
|
if _, err := w.Write(t.Data); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (t *Block) 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")
|
|
}
|
|
|
|
// t.Prefix ([]uint8) (slice)
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if extra > cbg.ByteArrayMaxLen {
|
|
return fmt.Errorf("t.Prefix: byte array too large (%d)", extra)
|
|
}
|
|
if maj != cbg.MajByteString {
|
|
return fmt.Errorf("expected byte array")
|
|
}
|
|
t.Prefix = make([]byte, extra)
|
|
if _, err := io.ReadFull(br, t.Prefix); err != nil {
|
|
return err
|
|
}
|
|
// t.Data ([]uint8) (slice)
|
|
|
|
maj, extra, err = cbg.CborReadHeader(br)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if extra > cbg.ByteArrayMaxLen {
|
|
return fmt.Errorf("t.Data: byte array too large (%d)", extra)
|
|
}
|
|
if maj != cbg.MajByteString {
|
|
return fmt.Errorf("expected byte array")
|
|
}
|
|
t.Data = make([]byte, extra)
|
|
if _, err := io.ReadFull(br, t.Data); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|