parent
6bff52483b
commit
6253c39100
@ -50,7 +50,7 @@ type StorageMiner interface {
|
|||||||
MarketImportDealData(ctx context.Context, propcid cid.Cid, path string) error
|
MarketImportDealData(ctx context.Context, propcid cid.Cid, path string) error
|
||||||
MarketListDeals(ctx context.Context) ([]storagemarket.StorageDeal, error)
|
MarketListDeals(ctx context.Context) ([]storagemarket.StorageDeal, error)
|
||||||
MarketListIncompleteDeals(ctx context.Context) ([]storagemarket.MinerDeal, error)
|
MarketListIncompleteDeals(ctx context.Context) ([]storagemarket.MinerDeal, error)
|
||||||
MarketSetPrice(context.Context, types.BigInt) error
|
MarketSetAsk(ctx context.Context, price types.BigInt, duration abi.ChainEpoch, minPieceSize abi.PaddedPieceSize, maxPieceSize abi.PaddedPieceSize) error
|
||||||
|
|
||||||
DealsImportData(ctx context.Context, dealPropCid cid.Cid, file string) error
|
DealsImportData(ctx context.Context, dealPropCid cid.Cid, file string) error
|
||||||
DealsList(ctx context.Context) ([]storagemarket.StorageDeal, error)
|
DealsList(ctx context.Context) ([]storagemarket.StorageDeal, error)
|
||||||
|
@ -192,10 +192,10 @@ type StorageMinerStruct struct {
|
|||||||
|
|
||||||
MiningBase func(context.Context) (*types.TipSet, error) `perm:"read"`
|
MiningBase func(context.Context) (*types.TipSet, error) `perm:"read"`
|
||||||
|
|
||||||
MarketImportDealData func(context.Context, cid.Cid, string) error `perm:"write"`
|
MarketImportDealData func(context.Context, cid.Cid, string) error `perm:"write"`
|
||||||
MarketListDeals func(ctx context.Context) ([]storagemarket.StorageDeal, error) `perm:"read"`
|
MarketListDeals func(ctx context.Context) ([]storagemarket.StorageDeal, error) `perm:"read"`
|
||||||
MarketListIncompleteDeals func(ctx context.Context) ([]storagemarket.MinerDeal, error) `perm:"read"`
|
MarketListIncompleteDeals func(ctx context.Context) ([]storagemarket.MinerDeal, error) `perm:"read"`
|
||||||
MarketSetPrice func(context.Context, types.BigInt) error `perm:"admin"`
|
MarketSetAsk func(ctx context.Context, price types.BigInt, duration abi.ChainEpoch, minPieceSize abi.PaddedPieceSize, maxPieceSize abi.PaddedPieceSize) error `perm:"admin"`
|
||||||
|
|
||||||
PledgeSector func(context.Context) error `perm:"write"`
|
PledgeSector func(context.Context) error `perm:"write"`
|
||||||
|
|
||||||
@ -841,8 +841,8 @@ func (c *StorageMinerStruct) MarketListIncompleteDeals(ctx context.Context) ([]s
|
|||||||
return c.Internal.MarketListIncompleteDeals(ctx)
|
return c.Internal.MarketListIncompleteDeals(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) MarketSetPrice(ctx context.Context, p types.BigInt) error {
|
func (c *StorageMinerStruct) MarketSetAsk(ctx context.Context, price types.BigInt, duration abi.ChainEpoch, minPieceSize abi.PaddedPieceSize, maxPieceSize abi.PaddedPieceSize) error {
|
||||||
return c.Internal.MarketSetPrice(ctx, p)
|
return c.Internal.MarketSetAsk(ctx, price, duration, minPieceSize, maxPieceSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) DealsImportData(ctx context.Context, dealPropCid cid.Cid, file string) error {
|
func (c *StorageMinerStruct) DealsImportData(ctx context.Context, dealPropCid cid.Cid, file string) error {
|
||||||
|
@ -30,7 +30,6 @@ func main() {
|
|||||||
stopCmd,
|
stopCmd,
|
||||||
sectorsCmd,
|
sectorsCmd,
|
||||||
storageCmd,
|
storageCmd,
|
||||||
setPriceCmd,
|
|
||||||
workersCmd,
|
workersCmd,
|
||||||
provingCmd,
|
provingCmd,
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,13 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/docker/go-units"
|
||||||
lcli "github.com/filecoin-project/lotus/cli"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
lcli "github.com/filecoin-project/lotus/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
var enableCmd = &cli.Command{
|
var enableCmd = &cli.Command{
|
||||||
@ -40,29 +43,70 @@ var disableCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var setPriceCmd = &cli.Command{
|
var setAskCmd = &cli.Command{
|
||||||
Name: "set-price",
|
Name: "set-ask",
|
||||||
Usage: "Set price that miner will accept storage deals at (FIL / GiB / Epoch)",
|
Usage: "Configure the miner's ask",
|
||||||
Flags: []cli.Flag{},
|
Flags: []cli.Flag{
|
||||||
|
&cli.Uint64Flag{
|
||||||
|
Name: "price",
|
||||||
|
Usage: "Set the price of the ask (specified as FIL / GiB / Epoch) to `PRICE`",
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
&cli.Uint64Flag{
|
||||||
|
Name: "duration",
|
||||||
|
Usage: "Set the duration (specified as epochs) of the ask to `DURATION`",
|
||||||
|
DefaultText: "8640000",
|
||||||
|
Value: 8640000,
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "min-piece-size",
|
||||||
|
Usage: "Set minimum piece size (without bit-padding, in bytes) in ask to `SIZE`",
|
||||||
|
DefaultText: "254B",
|
||||||
|
Value: "254B",
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "max-piece-size",
|
||||||
|
Usage: "Set maximum piece size (without bit-padding, in bytes) in ask to `SIZE`",
|
||||||
|
DefaultText: "miner sector size, without bit-padding",
|
||||||
|
},
|
||||||
|
},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
|
ctx := lcli.DaemonContext(cctx)
|
||||||
|
|
||||||
api, closer, err := lcli.GetStorageMinerAPI(cctx)
|
api, closer, err := lcli.GetStorageMinerAPI(cctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer closer()
|
defer closer()
|
||||||
|
|
||||||
ctx := lcli.DaemonContext(cctx)
|
pri := types.NewInt(cctx.Uint64("price"))
|
||||||
|
dur := abi.ChainEpoch(cctx.Uint64("duration"))
|
||||||
|
|
||||||
if !cctx.Args().Present() {
|
min, err := units.RAMInBytes(cctx.String("min-piece-size"))
|
||||||
return fmt.Errorf("must specify price to set")
|
|
||||||
}
|
|
||||||
|
|
||||||
fp, err := types.ParseFIL(cctx.Args().First())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return api.MarketSetPrice(ctx, types.BigInt(fp))
|
max, err := units.RAMInBytes(cctx.String("max-piece-size"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if max == 0 {
|
||||||
|
maddr, err := api.ActorAddress(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize, err := api.ActorSectorSize(ctx, maddr)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
max = int64(abi.PaddedPieceSize(ssize).Unpadded())
|
||||||
|
}
|
||||||
|
|
||||||
|
return api.MarketSetAsk(ctx, pri, dur, abi.UnpaddedPieceSize(min).Padded(), abi.UnpaddedPieceSize(max).Padded())
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +118,7 @@ var dealsCmd = &cli.Command{
|
|||||||
dealsListCmd,
|
dealsListCmd,
|
||||||
enableCmd,
|
enableCmd,
|
||||||
disableCmd,
|
disableCmd,
|
||||||
|
setAskCmd,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,8 +201,13 @@ func (sm *StorageMinerAPI) MarketListIncompleteDeals(ctx context.Context) ([]sto
|
|||||||
return sm.StorageProvider.ListLocalDeals()
|
return sm.StorageProvider.ListLocalDeals()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StorageMinerAPI) MarketSetPrice(ctx context.Context, p types.BigInt) error {
|
func (sm *StorageMinerAPI) MarketSetAsk(ctx context.Context, price types.BigInt, duration abi.ChainEpoch, minPieceSize abi.PaddedPieceSize, maxPieceSize abi.PaddedPieceSize) error {
|
||||||
return sm.StorageProvider.SetAsk(p, 60*60*24*100) // lasts for 100 days?
|
options := []storagemarket.StorageAskOption{
|
||||||
|
storagemarket.MinPieceSize(minPieceSize),
|
||||||
|
storagemarket.MaxPieceSize(maxPieceSize),
|
||||||
|
}
|
||||||
|
|
||||||
|
return sm.StorageProvider.SetAsk(price, duration, options...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StorageMinerAPI) DealsList(ctx context.Context) ([]storagemarket.StorageDeal, error) {
|
func (sm *StorageMinerAPI) DealsList(ctx context.Context) ([]storagemarket.StorageDeal, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user