2021-11-17 11:14:10 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/fatih/color"
|
2022-06-14 15:00:51 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
2021-11-17 11:14:10 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
|
|
|
|
lcli "github.com/filecoin-project/lotus/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
var indexProvCmd = &cli.Command{
|
|
|
|
Name: "index",
|
|
|
|
Usage: "Manage the index provider on the markets subsystem",
|
|
|
|
Subcommands: []*cli.Command{
|
|
|
|
indexProvAnnounceCmd,
|
2022-01-12 14:06:48 +00:00
|
|
|
indexProvAnnounceAllCmd,
|
2021-11-17 11:14:10 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
var indexProvAnnounceCmd = &cli.Command{
|
|
|
|
Name: "announce",
|
|
|
|
ArgsUsage: "<deal proposal cid>",
|
|
|
|
Usage: "Announce a deal to indexers so they can download its index",
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
&cli.BoolFlag{
|
|
|
|
Name: "color",
|
|
|
|
Usage: "use color in display output",
|
|
|
|
DefaultText: "depends on output being a TTY",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Action: func(cctx *cli.Context) error {
|
|
|
|
if cctx.IsSet("color") {
|
|
|
|
color.NoColor = !cctx.Bool("color")
|
|
|
|
}
|
|
|
|
|
|
|
|
if cctx.NArg() != 1 {
|
|
|
|
return fmt.Errorf("must provide the deal proposal CID")
|
|
|
|
}
|
|
|
|
|
|
|
|
proposalCidStr := cctx.Args().First()
|
|
|
|
proposalCid, err := cid.Parse(proposalCidStr)
|
|
|
|
if err != nil {
|
2021-11-17 11:37:15 +00:00
|
|
|
return fmt.Errorf("invalid deal proposal CID: %w", err)
|
2021-11-17 11:14:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
marketsApi, closer, err := lcli.GetMarketsAPI(cctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer closer()
|
|
|
|
|
|
|
|
ctx := lcli.ReqContext(cctx)
|
|
|
|
|
|
|
|
return marketsApi.IndexerAnnounceDeal(ctx, proposalCid)
|
|
|
|
},
|
|
|
|
}
|
2022-01-12 14:06:48 +00:00
|
|
|
|
|
|
|
var indexProvAnnounceAllCmd = &cli.Command{
|
|
|
|
Name: "announce-all",
|
2022-03-02 11:04:50 +00:00
|
|
|
Usage: "Announce all active deals to indexers so they can download the indices",
|
2022-01-12 14:06:48 +00:00
|
|
|
Flags: []cli.Flag{
|
|
|
|
&cli.BoolFlag{
|
|
|
|
Name: "color",
|
|
|
|
Usage: "use color in display output",
|
|
|
|
DefaultText: "depends on output being a TTY",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Action: func(cctx *cli.Context) error {
|
|
|
|
if cctx.IsSet("color") {
|
|
|
|
color.NoColor = !cctx.Bool("color")
|
|
|
|
}
|
|
|
|
|
|
|
|
marketsApi, closer, err := lcli.GetMarketsAPI(cctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer closer()
|
|
|
|
|
|
|
|
ctx := lcli.ReqContext(cctx)
|
|
|
|
|
|
|
|
return marketsApi.IndexerAnnounceAllDeals(ctx)
|
|
|
|
},
|
|
|
|
}
|