wire up lotus side of make deal for manual commP

This commit is contained in:
whyrusleeping
2020-03-03 16:18:08 -08:00
parent 99c842e027
commit 2be2891647
5 changed files with 57 additions and 24 deletions
+11 -11
View File
@@ -58,26 +58,26 @@ type API struct {
Filestore dtypes.ClientFilestore `optional:"true"`
}
func (a *API) ClientStartDeal(ctx context.Context, data *storagemarket.DataRef, addr address.Address, miner address.Address, epochPrice types.BigInt, blocksDuration uint64) (*cid.Cid, error) {
exist, err := a.WalletHas(ctx, addr)
func (a *API) ClientStartDeal(ctx context.Context, params *api.StartDealParams) (*cid.Cid, error) {
exist, err := a.WalletHas(ctx, params.Wallet)
if err != nil {
return nil, xerrors.Errorf("failed getting addr from wallet: %w", addr)
return nil, xerrors.Errorf("failed getting addr from wallet: %w", params.Wallet)
}
if !exist {
return nil, xerrors.Errorf("provided address doesn't exist in wallet")
}
pid, err := a.StateMinerPeerID(ctx, miner, types.EmptyTSK)
pid, err := a.StateMinerPeerID(ctx, params.Miner, types.EmptyTSK)
if err != nil {
return nil, xerrors.Errorf("failed getting peer ID: %w", err)
}
mw, err := a.StateMinerWorker(ctx, miner, types.EmptyTSK)
mw, err := a.StateMinerWorker(ctx, params.Miner, types.EmptyTSK)
if err != nil {
return nil, xerrors.Errorf("failed getting miner worker: %w", err)
}
ssize, err := a.StateMinerSectorSize(ctx, miner, types.EmptyTSK)
ssize, err := a.StateMinerSectorSize(ctx, params.Miner, types.EmptyTSK)
if err != nil {
return nil, xerrors.Errorf("failed checking miners sector size: %w", err)
}
@@ -87,19 +87,19 @@ func (a *API) ClientStartDeal(ctx context.Context, data *storagemarket.DataRef,
return nil, xerrors.Errorf("bad sector size: %w", err)
}
providerInfo := utils.NewStorageProviderInfo(miner, mw, 0, pid)
providerInfo := utils.NewStorageProviderInfo(params.Miner, mw, 0, pid)
ts, err := a.ChainHead(ctx)
if err != nil {
return nil, xerrors.Errorf("failed getting chain height: %w", err)
}
result, err := a.SMDealClient.ProposeStorageDeal(
ctx,
addr,
params.Wallet,
&providerInfo,
data,
params.Data,
ts.Height()+dealStartBuffer,
ts.Height()+dealStartBuffer+abi.ChainEpoch(blocksDuration),
epochPrice,
ts.Height()+dealStartBuffer+abi.ChainEpoch(params.BlocksDuration),
params.EpochPrice,
big.Zero(),
rt,
)