feat(markets): use non-custom go-fil-markets, from master

This commit is contained in:
hannahhoward
2020-02-12 14:32:26 -08:00
parent 220bd376b4
commit 720e29848b
8 changed files with 43 additions and 211 deletions
+16 -9
View File
@@ -25,7 +25,6 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
"github.com/filecoin-project/go-fil-markets/shared/tokenamount"
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
@@ -35,8 +34,11 @@ 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
type API struct {
fx.In
@@ -74,14 +76,19 @@ func (a *API) ClientStartDeal(ctx context.Context, data cid.Cid, addr address.Ad
return nil, xerrors.Errorf("failed getting miner worker: %w", err)
}
providerInfo := utils.NewStorageProviderInfo(miner, mw, 0, pid)
ts, err := a.ChainHead(ctx)
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.Epoch(math.MaxUint64),
storagemarket.Epoch(blocksDuration),
utils.ToSharedTokenAmount(epochPrice),
ts.Height()+dealStartBuffer,
ts.Height()+dealStartBuffer+abi.ChainEpoch(blocksDuration),
epochPrice,
tokenamount.Empty)
if err != nil {
@@ -107,7 +114,7 @@ func (a *API) ClientListDeals(ctx context.Context) ([]api.DealInfo, error) {
PieceRef: v.Proposal.PieceRef,
Size: v.Proposal.PieceSize,
PricePerEpoch: utils.FromSharedTokenAmount(v.Proposal.StoragePricePerEpoch),
PricePerEpoch: v.Proposal.StoragePricePerEpoch,
Duration: v.Proposal.Duration,
}
}
@@ -127,7 +134,7 @@ func (a *API) ClientGetDealInfo(ctx context.Context, d cid.Cid) (*api.DealInfo,
Provider: v.Proposal.Provider,
PieceRef: v.Proposal.PieceRef,
Size: v.Proposal.PieceSize,
PricePerEpoch: utils.FromSharedTokenAmount(v.Proposal.StoragePricePerEpoch),
PricePerEpoch: v.Proposal.StoragePricePerEpoch,
Duration: v.Proposal.Duration,
}, nil
}
@@ -161,7 +168,7 @@ func (a *API) ClientFindData(ctx context.Context, root cid.Cid) ([]api.QueryOffe
out[k] = api.QueryOffer{
Root: root,
Size: queryResponse.Size,
MinPrice: utils.FromSharedTokenAmount(queryResponse.PieceRetrievalPrice()),
MinPrice: queryResponse.PieceRetrievalPrice(),
PaymentInterval: queryResponse.MaxPaymentInterval,
PaymentIntervalIncrease: queryResponse.MaxPaymentIntervalIncrease,
Miner: p.Address, // TODO: check
@@ -294,7 +301,7 @@ func (a *API) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, path
ctx,
order.Root,
retrievalmarket.NewParamsV0(types.BigDiv(order.Total, types.NewInt(order.Size)).Int, order.PaymentInterval, order.PaymentIntervalIncrease),
utils.ToSharedTokenAmount(order.Total),
order.Total,
order.MinerPeerID,
order.Client,
order.Miner)
@@ -326,5 +333,5 @@ func (a *API) ClientQueryAsk(ctx context.Context, p peer.ID, miner address.Addre
if err != nil {
return nil, err
}
return utils.FromSignedStorageAsk(signedAsk)
return signedAsk
}