Fix client market impl, gofmt

This commit is contained in:
Łukasz Magiera 2020-02-13 01:15:33 +01:00
parent 91b2d2c2fe
commit e5ab64a3ab
9 changed files with 55 additions and 55 deletions

View File

@ -183,7 +183,6 @@ func (st *StateTree) RegisterNewAddress(addr address.Address, act *types.Actor)
return out, nil
}
type adtStore struct{ cbor.IpldStore }
func (a *adtStore) Context() context.Context {

View File

@ -2,6 +2,7 @@ package types
import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-fil-markets/storagemarket"
cbor "github.com/ipfs/go-ipld-cbor"
)
@ -10,10 +11,7 @@ func init() {
cbor.RegisterCborType(StorageAsk{})
}
type SignedStorageAsk struct {
Ask *StorageAsk
Signature *Signature
}
type SignedStorageAsk = storagemarket.SignedStorageAsk
type StorageAsk struct {
// Price per GiB / Epoch

View File

@ -10,6 +10,7 @@ import (
)
type ActorType string
const (
TAccount ActorType = "account"
TMultisig ActorType = "multisig"

View File

@ -4,9 +4,9 @@ import (
"context"
"errors"
"io"
"math"
"os"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"golang.org/x/xerrors"
"github.com/ipfs/go-blockservice"
@ -26,6 +26,8 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/store"
@ -34,10 +36,9 @@ import (
"github.com/filecoin-project/lotus/node/impl/full"
"github.com/filecoin-project/lotus/node/impl/paych"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/specs-actors/actors/abi"
)
const dealStartBuffer abi.ChainEpoch 100
const dealStartBuffer abi.ChainEpoch = 10000 // TODO: allow setting
type API struct {
fx.In
@ -80,16 +81,18 @@ func (a *API) ClientStartDeal(ctx context.Context, data cid.Cid, addr address.Ad
if err != nil {
return nil, xerrors.Errorf("failed getting chain height: %w", err)
}
currentEpoch := ts.Height()
result, err := a.SMDealClient.ProposeStorageDeal(
ctx,
addr,
&providerInfo,
data,
&storagemarket.DataRef{
TransferType: storagemarket.TTGraphsync,
Root: data,
},
ts.Height()+dealStartBuffer,
ts.Height()+dealStartBuffer+abi.ChainEpoch(blocksDuration),
epochPrice,
tokenamount.Empty)
big.Zero())
if err != nil {
return nil, xerrors.Errorf("failed to start deal: %w", err)
@ -111,11 +114,11 @@ func (a *API) ClientListDeals(ctx context.Context) ([]api.DealInfo, error) {
State: v.State,
Provider: v.Proposal.Provider,
PieceRef: v.Proposal.PieceRef,
Size: v.Proposal.PieceSize,
PieceRef: v.Proposal.PieceCID.Bytes(),
Size: uint64(v.Proposal.PieceSize.Unpadded()),
PricePerEpoch: v.Proposal.StoragePricePerEpoch,
Duration: v.Proposal.Duration,
Duration: uint64(v.Proposal.Duration()),
}
}
@ -132,10 +135,10 @@ func (a *API) ClientGetDealInfo(ctx context.Context, d cid.Cid) (*api.DealInfo,
ProposalCid: v.ProposalCid,
State: v.State,
Provider: v.Proposal.Provider,
PieceRef: v.Proposal.PieceRef,
Size: v.Proposal.PieceSize,
PieceRef: v.Proposal.PieceCID.Bytes(),
Size: uint64(v.Proposal.PieceSize.Unpadded()),
PricePerEpoch: v.Proposal.StoragePricePerEpoch,
Duration: v.Proposal.Duration,
Duration: uint64(v.Proposal.Duration()),
}, nil
}
@ -300,7 +303,7 @@ func (a *API) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, path
a.Retrieval.Retrieve(
ctx,
order.Root,
retrievalmarket.NewParamsV0(types.BigDiv(order.Total, types.NewInt(order.Size)).Int, order.PaymentInterval, order.PaymentIntervalIncrease),
retrievalmarket.NewParamsV0(types.BigDiv(order.Total, types.NewInt(order.Size)), order.PaymentInterval, order.PaymentIntervalIncrease),
order.Total,
order.MinerPeerID,
order.Client,
@ -327,11 +330,11 @@ func (a *API) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, path
return files.WriteTo(file, path)
}
func (a *API) ClientQueryAsk(ctx context.Context, p peer.ID, miner address.Address) (*types.SignedStorageAsk, error) {
func (a *API) ClientQueryAsk(ctx context.Context, p peer.ID, miner address.Address) (*storagemarket.SignedStorageAsk, error) {
info := utils.NewStorageProviderInfo(miner, address.Undef, 0, p)
signedAsk, err := a.SMDealClient.GetAsk(ctx, info)
if err != nil {
return nil, err
}
return signedAsk
return signedAsk, nil
}

View File

@ -107,7 +107,6 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf
SealEpoch: sector.Ticket.BlockHeight,
DealIDs: nil, // sector.deals(), // TODO: REFACTOR
},
}
enc, aerr := actors.SerializeParams(params)
if aerr != nil {