diff --git a/chain/types/ask.go b/chain/types/ask.go index a1470f251..09f751a63 100644 --- a/chain/types/ask.go +++ b/chain/types/ask.go @@ -1,25 +1,9 @@ package types import ( - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-fil-markets/storagemarket" - cbor "github.com/ipfs/go-ipld-cbor" ) -func init() { - cbor.RegisterCborType(SignedStorageAsk{}) - cbor.RegisterCborType(StorageAsk{}) -} - type SignedStorageAsk = storagemarket.SignedStorageAsk -type StorageAsk struct { - // Price per GiB / Epoch - Price BigInt - - MinPieceSize uint64 - Miner address.Address - Timestamp uint64 - Expiry uint64 - SeqNo uint64 -} +type StorageAsk = storagemarket.StorageAsk \ No newline at end of file diff --git a/chain/types/cbor_gen.go b/chain/types/cbor_gen.go index a502f34b3..771cd4e3c 100644 --- a/chain/types/cbor_gen.go +++ b/chain/types/cbor_gen.go @@ -1187,204 +1187,6 @@ func (t *BlockMsg) UnmarshalCBOR(r io.Reader) error { return nil } -func (t *SignedStorageAsk) 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.Ask (types.StorageAsk) (struct) - if err := t.Ask.MarshalCBOR(w); err != nil { - return err - } - - // t.Signature (types.Signature) (struct) - if err := t.Signature.MarshalCBOR(w); err != nil { - return err - } - return nil -} - -func (t *SignedStorageAsk) 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.Ask (types.StorageAsk) (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.Ask = new(StorageAsk) - if err := t.Ask.UnmarshalCBOR(br); err != nil { - return err - } - } - - } - // t.Signature (types.Signature) (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.Signature = new(Signature) - if err := t.Signature.UnmarshalCBOR(br); err != nil { - return err - } - } - - } - return nil -} - -func (t *StorageAsk) MarshalCBOR(w io.Writer) error { - if t == nil { - _, err := w.Write(cbg.CborNull) - return err - } - if _, err := w.Write([]byte{134}); err != nil { - return err - } - - // t.Price (big.Int) (struct) - if err := t.Price.MarshalCBOR(w); err != nil { - return err - } - - // t.MinPieceSize (uint64) (uint64) - if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.MinPieceSize))); err != nil { - return err - } - - // t.Miner (address.Address) (struct) - if err := t.Miner.MarshalCBOR(w); err != nil { - return err - } - - // t.Timestamp (uint64) (uint64) - if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Timestamp))); err != nil { - return err - } - - // t.Expiry (uint64) (uint64) - if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Expiry))); err != nil { - return err - } - - // t.SeqNo (uint64) (uint64) - if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SeqNo))); err != nil { - return err - } - return nil -} - -func (t *StorageAsk) 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 != 6 { - return fmt.Errorf("cbor input had wrong number of fields") - } - - // t.Price (big.Int) (struct) - - { - - if err := t.Price.UnmarshalCBOR(br); err != nil { - return err - } - - } - // t.MinPieceSize (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.MinPieceSize = uint64(extra) - // t.Miner (address.Address) (struct) - - { - - if err := t.Miner.UnmarshalCBOR(br); err != nil { - return err - } - - } - // t.Timestamp (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.Timestamp = uint64(extra) - // t.Expiry (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.Expiry = uint64(extra) - // t.SeqNo (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.SeqNo = uint64(extra) - return nil -} - func (t *ExpTipSet) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) diff --git a/gen/main.go b/gen/main.go index 7ced19b50..a9bada5ff 100644 --- a/gen/main.go +++ b/gen/main.go @@ -10,7 +10,7 @@ import ( "github.com/filecoin-project/lotus/chain/blocksync" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/lib/statemachine" - "github.com/filecoin-project/lotus/paych" + "github.com/filecoin-project/lotus/paychmgr" "github.com/filecoin-project/lotus/storage/sealing" ) @@ -26,8 +26,6 @@ func main() { types.Actor{}, types.MessageReceipt{}, types.BlockMsg{}, - types.SignedStorageAsk{}, - types.StorageAsk{}, types.ExpTipSet{}, ) if err != nil { @@ -35,9 +33,9 @@ func main() { os.Exit(1) } - err = gen.WriteMapEncodersToFile("./paych/cbor_gen.go", "paych", - paych.VoucherInfo{}, - paych.ChannelInfo{}, + err = gen.WriteMapEncodersToFile("./paychmgr/cbor_gen.go", "paychmgr", + paychmgr.VoucherInfo{}, + paychmgr.ChannelInfo{}, ) if err != nil { fmt.Println(err) diff --git a/markets/retrievaladapter/client.go b/markets/retrievaladapter/client.go index 81458f02b..98f576603 100644 --- a/markets/retrievaladapter/client.go +++ b/markets/retrievaladapter/client.go @@ -6,18 +6,18 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-fil-markets/retrievalmarket" payapi "github.com/filecoin-project/lotus/node/impl/paych" - "github.com/filecoin-project/lotus/paych" + "github.com/filecoin-project/lotus/paychmgr" "github.com/filecoin-project/specs-actors/actors/abi" ) type retrievalClientNode struct { - pmgr *paych.Manager + pmgr *paychmgr.Manager payapi payapi.PaychAPI } // NewRetrievalClientNode returns a new node adapter for a retrieval client that talks to the // Lotus Node -func NewRetrievalClientNode(pmgr *paych.Manager, payapi payapi.PaychAPI) retrievalmarket.RetrievalClientNode { +func NewRetrievalClientNode(pmgr *paychmgr.Manager, payapi payapi.PaychAPI) retrievalmarket.RetrievalClientNode { return &retrievalClientNode{pmgr: pmgr, payapi: payapi} } @@ -38,7 +38,7 @@ func (rcn *retrievalClientNode) AllocateLane(paymentChannel address.Address) (ui // CreatePaymentVoucher creates a new payment voucher in the given lane for a // given payment channel so that all the payment vouchers in the lane add up // to the given amount (so the payment voucher will be for the difference) -func (rcn *retrievalClientNode) CreatePaymentVoucher(ctx context.Context, paymentChannel address.Address, amount abi.TokenAmount, lane uint64) (*paych.SignedVoucher, error) { +func (rcn *retrievalClientNode) CreatePaymentVoucher(ctx context.Context, paymentChannel address.Address, amount abi.TokenAmount, lane uint64) (*paychmgr.SignedVoucher, error) { voucher, err := rcn.payapi.PaychVoucherCreate(ctx, paymentChannel, amount, lane) if err != nil { return nil, err diff --git a/markets/retrievaladapter/provider.go b/markets/retrievaladapter/provider.go index f576404f2..ce423dd04 100644 --- a/markets/retrievaladapter/provider.go +++ b/markets/retrievaladapter/provider.go @@ -10,7 +10,7 @@ import ( "github.com/filecoin-project/go-sectorbuilder" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/paych" + "github.com/filecoin-project/lotus/paychmgr" "github.com/filecoin-project/lotus/storage" ) @@ -34,7 +34,7 @@ func (rpn *retrievalProviderNode) UnsealSector(ctx context.Context, sectorID abi return rpn.sb.ReadPieceFromSealedSector(ctx, sectorID, sectorbuilder.UnpaddedByteIndex(offset), abi.UnpaddedPieceSize(length), si.Ticket.TicketBytes, si.CommD) } -func (rpn *retrievalProviderNode) SavePaymentVoucher(ctx context.Context, paymentChannel address.Address, voucher *paych.SignedVoucher, proof []byte, expectedAmount abi.TokenAmount) (abi.TokenAmount, error) { +func (rpn *retrievalProviderNode) SavePaymentVoucher(ctx context.Context, paymentChannel address.Address, voucher *paychmgr.SignedVoucher, proof []byte, expectedAmount abi.TokenAmount) (abi.TokenAmount, error) { added, err := rpn.full.PaychVoucherAdd(ctx, paymentChannel, voucher, proof, expectedAmount) return added, err } diff --git a/node/builder.go b/node/builder.go index b42b93774..e937199a0 100644 --- a/node/builder.go +++ b/node/builder.go @@ -50,7 +50,7 @@ import ( "github.com/filecoin-project/lotus/node/modules/lp2p" "github.com/filecoin-project/lotus/node/modules/testing" "github.com/filecoin-project/lotus/node/repo" - "github.com/filecoin-project/lotus/paych" + "github.com/filecoin-project/lotus/paychmgr" "github.com/filecoin-project/lotus/peermgr" "github.com/filecoin-project/lotus/storage" "github.com/filecoin-project/lotus/storage/sealing" @@ -242,8 +242,8 @@ func Online() Option { Override(RegisterClientValidatorKey, modules.RegisterClientValidator), Override(RunDealClientKey, modules.RunDealClient), - Override(new(*paych.Store), paych.NewStore), - Override(new(*paych.Manager), paych.NewManager), + Override(new(*paychmgr.Store), paychmgr.NewStore), + Override(new(*paychmgr.Manager), paychmgr.NewManager), Override(new(*market.FundMgr), market.NewFundMgr), ), diff --git a/node/impl/paych/paych.go b/node/impl/paych/paych.go index 92ffdd9f5..5ed326717 100644 --- a/node/impl/paych/paych.go +++ b/node/impl/paych/paych.go @@ -13,7 +13,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" full "github.com/filecoin-project/lotus/node/impl/full" - "github.com/filecoin-project/lotus/paych" + "github.com/filecoin-project/lotus/paychmgr" ) type PaychAPI struct { @@ -23,7 +23,7 @@ type PaychAPI struct { full.WalletAPI full.ChainAPI - PaychMgr *paych.Manager + PaychMgr *paychmgr.Manager } func (a *PaychAPI) PaychGet(ctx context.Context, from, to address.Address, ensureFunds types.BigInt) (*api.ChannelInfo, error) { diff --git a/node/modules/client.go b/node/modules/client.go index 22b6bdab9..8fa27163e 100644 --- a/node/modules/client.go +++ b/node/modules/client.go @@ -36,7 +36,7 @@ import ( "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/modules/helpers" "github.com/filecoin-project/lotus/node/repo" - "github.com/filecoin-project/lotus/paych" + "github.com/filecoin-project/lotus/paychmgr" ) func ClientFstore(r repo.LockedRepo) (dtypes.ClientFilestore, error) { @@ -117,7 +117,7 @@ func StorageClient(h host.Host, ibs dtypes.ClientBlockstore, r repo.LockedRepo, } // RetrievalClient creates a new retrieval client attached to the client blockstore -func RetrievalClient(h host.Host, bs dtypes.ClientBlockstore, pmgr *paych.Manager, payapi payapi.PaychAPI, resolver retrievalmarket.PeerResolver) retrievalmarket.RetrievalClient { +func RetrievalClient(h host.Host, bs dtypes.ClientBlockstore, pmgr *paychmgr.Manager, payapi payapi.PaychAPI, resolver retrievalmarket.PeerResolver) retrievalmarket.RetrievalClient { adapter := retrievaladapter.NewRetrievalClientNode(pmgr, payapi) network := rmnet.NewFromLibp2pHost(h) return retrievalimpl.NewClient(network, bs, adapter, resolver) diff --git a/paych/cbor_gen.go b/paychmgr/cbor_gen.go similarity index 97% rename from paych/cbor_gen.go rename to paychmgr/cbor_gen.go index aa05262dc..002ee2f08 100644 --- a/paych/cbor_gen.go +++ b/paychmgr/cbor_gen.go @@ -1,11 +1,12 @@ // Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. -package paych +package paychmgr import ( "fmt" "io" + "github.com/filecoin-project/specs-actors/actors/builtin/paych" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" ) @@ -107,7 +108,7 @@ func (t *VoucherInfo) UnmarshalCBOR(r io.Reader) error { return err } } else { - t.Voucher = new(SignedVoucher) + t.Voucher = new(paych.SignedVoucher) if err := t.Voucher.UnmarshalCBOR(br); err != nil { return err } @@ -213,7 +214,7 @@ func (t *ChannelInfo) MarshalCBOR(w io.Writer) error { return err } - // t.Vouchers ([]*paych.VoucherInfo) (slice) + // t.Vouchers ([]*paychmgr.VoucherInfo) (slice) if len("Vouchers") > cbg.MaxLength { return xerrors.Errorf("Value in field \"Vouchers\" was too long") } @@ -327,7 +328,7 @@ func (t *ChannelInfo) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Direction = uint64(extra) - // t.Vouchers ([]*paych.VoucherInfo) (slice) + // t.Vouchers ([]*paychmgr.VoucherInfo) (slice) case "Vouchers": maj, extra, err = cbg.CborReadHeader(br) diff --git a/paych/paych.go b/paychmgr/paych.go similarity index 99% rename from paych/paych.go rename to paychmgr/paych.go index 239847c08..f5e43d195 100644 --- a/paych/paych.go +++ b/paychmgr/paych.go @@ -1,4 +1,4 @@ -package paych +package paychmgr import ( "bytes" diff --git a/paych/simple.go b/paychmgr/simple.go similarity index 99% rename from paych/simple.go rename to paychmgr/simple.go index a67a72ef1..007ed4c78 100644 --- a/paych/simple.go +++ b/paychmgr/simple.go @@ -1,4 +1,4 @@ -package paych +package paychmgr import ( "context" diff --git a/paych/state.go b/paychmgr/state.go similarity index 99% rename from paych/state.go rename to paychmgr/state.go index 6ec5f6acc..9f3b80261 100644 --- a/paych/state.go +++ b/paychmgr/state.go @@ -1,4 +1,4 @@ -package paych +package paychmgr import ( "context" diff --git a/paych/store.go b/paychmgr/store.go similarity index 99% rename from paych/store.go rename to paychmgr/store.go index 37ba61952..3a425c4fc 100644 --- a/paych/store.go +++ b/paychmgr/store.go @@ -1,4 +1,4 @@ -package paych +package paychmgr import ( "bytes"