add a new cli

This commit is contained in:
Aarsh Shah 2022-01-12 18:06:48 +04:00
parent 051d993d62
commit 8c8652e7bb
9 changed files with 76 additions and 2 deletions

View File

@ -223,6 +223,9 @@ type StorageMiner interface {
// so they can download its index
IndexerAnnounceDeal(ctx context.Context, proposalCid cid.Cid) error //perm:admin
// IndexerAnnounceAllDeals informs the indexer nodes aboutall active deals.
IndexerAnnounceAllDeals(ctx context.Context) error //perm:admin
// DagstorePieceIndexSize returns the size of the piece index.
DagstorePieceIndexSize(ctx context.Context) (int64, error) //perm:admin

View File

@ -671,6 +671,8 @@ type StorageMinerStruct struct {
DealsSetPieceCidBlocklist func(p0 context.Context, p1 []cid.Cid) error `perm:"admin"`
IndexerAnnounceAllDeals func(p0 context.Context) error `perm:"admin"`
IndexerAnnounceDeal func(p0 context.Context, p1 cid.Cid) error `perm:"admin"`
MarketCancelDataTransfer func(p0 context.Context, p1 datatransfer.TransferID, p2 peer.ID, p3 bool) error `perm:"write"`
@ -3994,6 +3996,17 @@ func (s *StorageMinerStub) DealsSetPieceCidBlocklist(p0 context.Context, p1 []ci
return ErrNotSupported
}
func (s *StorageMinerStruct) IndexerAnnounceAllDeals(p0 context.Context) error {
if s.Internal.IndexerAnnounceAllDeals == nil {
return ErrNotSupported
}
return s.Internal.IndexerAnnounceAllDeals(p0)
}
func (s *StorageMinerStub) IndexerAnnounceAllDeals(p0 context.Context) error {
return ErrNotSupported
}
func (s *StorageMinerStruct) IndexerAnnounceDeal(p0 context.Context, p1 cid.Cid) error {
if s.Internal.IndexerAnnounceDeal == nil {
return ErrNotSupported

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -16,6 +16,7 @@ var indexProvCmd = &cli.Command{
Usage: "Manage the index provider on the markets subsystem",
Subcommands: []*cli.Command{
indexProvAnnounceCmd,
indexProvAnnounceAllCmd,
},
}
@ -56,3 +57,30 @@ var indexProvAnnounceCmd = &cli.Command{
return marketsApi.IndexerAnnounceDeal(ctx, proposalCid)
},
}
var indexProvAnnounceAllCmd = &cli.Command{
Name: "announce-all",
Usage: "Announce all active deals to indexers so they can download its indices",
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)
},
}

View File

@ -46,6 +46,7 @@
* [I](#I)
* [ID](#ID)
* [Indexer](#Indexer)
* [IndexerAnnounceAllDeals](#IndexerAnnounceAllDeals)
* [IndexerAnnounceDeal](#IndexerAnnounceDeal)
* [Log](#Log)
* [LogAlerts](#LogAlerts)
@ -810,6 +811,16 @@ Response: `"12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf"`
## Indexer
### IndexerAnnounceAllDeals
IndexerAnnounceAllDeals informs the indexer nodes aboutall active deals.
Perms: admin
Inputs: `null`
Response: `{}`
### IndexerAnnounceDeal
IndexerAnnounceDeal informs indexer nodes that a new deal was received,
so they can download its index

View File

@ -1168,8 +1168,9 @@ USAGE:
lotus-miner index command [command options] [arguments...]
COMMANDS:
announce Announce a deal to indexers so they can download its index
help, h Shows a list of commands or help for one command
announce Announce a deal to indexers so they can download its index
announce-all Announce all active deals to indexers so they can download its indices
help, h Shows a list of commands or help for one command
OPTIONS:
--help, -h show help (default: false)
@ -1190,6 +1191,20 @@ OPTIONS:
```
### lotus-miner index announce-all
```
NAME:
lotus-miner index announce-all - Announce all active deals to indexers so they can download its indices
USAGE:
lotus-miner index announce-all [command options] [arguments...]
OPTIONS:
--color use color in display output (default: depends on output being a TTY)
--help, -h show help (default: false)
```
## lotus-miner net
```
NAME:

View File

@ -1008,6 +1008,10 @@ func (sm *StorageMinerAPI) IndexerAnnounceDeal(ctx context.Context, proposalCid
return sm.StorageProvider.AnnounceDealToIndexer(ctx, proposalCid)
}
func (sm *StorageMinerAPI) IndexerAnnounceAllDeals(ctx context.Context) error {
return sm.StorageProvider.AnnounceAllDealsToIndexer(ctx)
}
func (sm *StorageMinerAPI) DagstorePieceIndexSize(ctx context.Context) (int64, error) {
if sm.DAGStore == nil {
return 0, fmt.Errorf("dagstore not available on this node")