Add flag to specify deal start epoch
This commit is contained in:
parent
f16ae9dffb
commit
e345525672
@ -331,6 +331,7 @@ type StartDealParams struct {
|
|||||||
Miner address.Address
|
Miner address.Address
|
||||||
EpochPrice types.BigInt
|
EpochPrice types.BigInt
|
||||||
MinBlocksDuration uint64
|
MinBlocksDuration uint64
|
||||||
|
DealStartEpoch abi.ChainEpoch
|
||||||
}
|
}
|
||||||
|
|
||||||
type IpldObject struct {
|
type IpldObject struct {
|
||||||
|
@ -173,6 +173,11 @@ var clientDealCmd = &cli.Command{
|
|||||||
Name: "from",
|
Name: "from",
|
||||||
Usage: "specify address to fund the deal with",
|
Usage: "specify address to fund the deal with",
|
||||||
},
|
},
|
||||||
|
&cli.Int64Flag{
|
||||||
|
Name: "start-epoch",
|
||||||
|
Usage: "specify the epoch that the deal should start at",
|
||||||
|
Value: -1,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
api, closer, err := GetFullNodeAPI(cctx)
|
api, closer, err := GetFullNodeAPI(cctx)
|
||||||
@ -252,6 +257,7 @@ var clientDealCmd = &cli.Command{
|
|||||||
Miner: miner,
|
Miner: miner,
|
||||||
EpochPrice: types.BigInt(price),
|
EpochPrice: types.BigInt(price),
|
||||||
MinBlocksDuration: uint64(dur),
|
MinBlocksDuration: uint64(dur),
|
||||||
|
DealStartEpoch: abi.ChainEpoch(cctx.Int64("start-epoch")),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -3,6 +3,7 @@ package client
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-fil-markets/pieceio"
|
"github.com/filecoin-project/go-fil-markets/pieceio"
|
||||||
ipldfree "github.com/ipld/go-ipld-prime/impl/free"
|
ipldfree "github.com/ipld/go-ipld-prime/impl/free"
|
||||||
"github.com/ipld/go-ipld-prime/traversal/selector"
|
"github.com/ipld/go-ipld-prime/traversal/selector"
|
||||||
@ -66,9 +67,9 @@ type API struct {
|
|||||||
Filestore dtypes.ClientFilestore `optional:"true"`
|
Filestore dtypes.ClientFilestore `optional:"true"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func calcDealExpiration(minDuration uint64, md *miner.DeadlineInfo, ts *types.TipSet) abi.ChainEpoch {
|
func calcDealExpiration(minDuration uint64, md *miner.DeadlineInfo, startEpoch abi.ChainEpoch) abi.ChainEpoch {
|
||||||
// Make sure we give some time for the miner to seal
|
// Make sure we give some time for the miner to seal
|
||||||
minExp := ts.Height() + dealStartBuffer + abi.ChainEpoch(minDuration)
|
minExp := startEpoch + abi.ChainEpoch(minDuration)
|
||||||
|
|
||||||
// Align on miners ProvingPeriodBoundary
|
// Align on miners ProvingPeriodBoundary
|
||||||
return minExp + miner.WPoStProvingPeriod - (minExp % miner.WPoStProvingPeriod) + (md.PeriodStart % miner.WPoStProvingPeriod) - 1
|
return minExp + miner.WPoStProvingPeriod - (minExp % miner.WPoStProvingPeriod) + (md.PeriodStart % miner.WPoStProvingPeriod) - 1
|
||||||
@ -103,18 +104,24 @@ func (a *API) ClientStartDeal(ctx context.Context, params *api.StartDealParams)
|
|||||||
}
|
}
|
||||||
|
|
||||||
providerInfo := utils.NewStorageProviderInfo(params.Miner, mi.Worker, mi.SectorSize, mi.PeerId)
|
providerInfo := utils.NewStorageProviderInfo(params.Miner, mi.Worker, mi.SectorSize, mi.PeerId)
|
||||||
|
|
||||||
|
dealStart := params.DealStartEpoch
|
||||||
|
if dealStart <= 0 { // unset, or explicitly 'epoch undefined'
|
||||||
ts, err := a.ChainHead(ctx)
|
ts, err := a.ChainHead(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("failed getting chain height: %w", err)
|
return nil, xerrors.Errorf("failed getting chain height: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dealStart = ts.Height() + dealStartBuffer
|
||||||
|
}
|
||||||
|
|
||||||
result, err := a.SMDealClient.ProposeStorageDeal(
|
result, err := a.SMDealClient.ProposeStorageDeal(
|
||||||
ctx,
|
ctx,
|
||||||
params.Wallet,
|
params.Wallet,
|
||||||
&providerInfo,
|
&providerInfo,
|
||||||
params.Data,
|
params.Data,
|
||||||
ts.Height()+dealStartBuffer,
|
dealStart,
|
||||||
calcDealExpiration(params.MinBlocksDuration, md, ts),
|
calcDealExpiration(params.MinBlocksDuration, md, dealStart),
|
||||||
params.EpochPrice,
|
params.EpochPrice,
|
||||||
big.Zero(),
|
big.Zero(),
|
||||||
rt,
|
rt,
|
||||||
|
Loading…
Reference in New Issue
Block a user