Rename paych -> paychmgr to fix cbor-gen

This commit is contained in:
Łukasz Magiera 2020-02-13 01:28:23 +01:00
parent e5ab64a3ab
commit e1a593c22e
13 changed files with 27 additions and 242 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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
}

View File

@ -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),
),

View File

@ -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) {

View File

@ -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)

View File

@ -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)

View File

@ -1,4 +1,4 @@
package paych
package paychmgr
import (
"bytes"

View File

@ -1,4 +1,4 @@
package paych
package paychmgr
import (
"context"

View File

@ -1,4 +1,4 @@
package paych
package paychmgr
import (
"context"

View File

@ -1,4 +1,4 @@
package paych
package paychmgr
import (
"bytes"