2020-06-23 17:17:31 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-06-26 17:33:06 +00:00
|
|
|
"fmt"
|
|
|
|
|
2020-06-23 17:17:31 +00:00
|
|
|
lcli "github.com/filecoin-project/lotus/cli"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
var retrievalDealsCmd = &cli.Command{
|
|
|
|
Name: "retrieval-deals",
|
|
|
|
Usage: "Manage retrieval deals and related configuration",
|
|
|
|
Subcommands: []*cli.Command{
|
2020-06-26 17:33:06 +00:00
|
|
|
retrievalDealSelectionCmd,
|
2020-06-23 17:17:31 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-06-26 17:33:06 +00:00
|
|
|
var retrievalDealSelectionCmd = &cli.Command{
|
|
|
|
Name: "selection",
|
|
|
|
Usage: "Configure acceptance criteria for retrieval deal proposals",
|
|
|
|
Subcommands: []*cli.Command{
|
|
|
|
retrievalDealSelectionShowCmd,
|
|
|
|
retrievalDealSelectionResetCmd,
|
|
|
|
retrievalDealSelectionRejectCmd,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
var retrievalDealSelectionShowCmd = &cli.Command{
|
|
|
|
Name: "list",
|
|
|
|
Usage: "List retrieval deal proposal selection criteria",
|
2020-06-23 17:17:31 +00:00
|
|
|
Action: func(cctx *cli.Context) error {
|
2020-06-26 17:33:06 +00:00
|
|
|
smapi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
2020-06-23 17:17:31 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer closer()
|
|
|
|
|
2020-06-26 19:27:41 +00:00
|
|
|
onlineOk, err := smapi.DealsConsiderOnlineRetrievalDeals(lcli.DaemonContext(cctx))
|
2020-06-26 17:33:06 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-06-26 19:27:41 +00:00
|
|
|
offlineOk, err := smapi.DealsConsiderOfflineRetrievalDeals(lcli.DaemonContext(cctx))
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Printf("considering online retrieval deals: %t\n", onlineOk)
|
|
|
|
fmt.Printf("considering offline retrieval deals: %t\n", offlineOk)
|
2020-06-26 17:33:06 +00:00
|
|
|
|
|
|
|
return nil
|
2020-06-23 17:17:31 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-06-26 17:33:06 +00:00
|
|
|
var retrievalDealSelectionResetCmd = &cli.Command{
|
|
|
|
Name: "reset",
|
|
|
|
Usage: "Reset retrieval deal proposal selection criteria to default values",
|
2020-06-23 17:17:31 +00:00
|
|
|
Action: func(cctx *cli.Context) error {
|
2020-06-26 17:33:06 +00:00
|
|
|
smapi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
2020-06-23 17:17:31 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer closer()
|
|
|
|
|
2020-06-26 17:50:54 +00:00
|
|
|
err = smapi.DealsSetConsiderOnlineRetrievalDeals(lcli.DaemonContext(cctx), true)
|
2020-06-26 17:33:06 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-06-26 19:27:41 +00:00
|
|
|
err = smapi.DealsSetConsiderOfflineRetrievalDeals(lcli.DaemonContext(cctx), true)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-06-26 17:33:06 +00:00
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
var retrievalDealSelectionRejectCmd = &cli.Command{
|
|
|
|
Name: "reject",
|
|
|
|
Usage: "Configure criteria which necessitate automatic rejection",
|
2020-06-26 19:27:41 +00:00
|
|
|
Flags: []cli.Flag{
|
|
|
|
&cli.BoolFlag{
|
|
|
|
Name: "online",
|
|
|
|
},
|
|
|
|
&cli.BoolFlag{
|
|
|
|
Name: "offline",
|
|
|
|
},
|
|
|
|
},
|
2020-06-26 17:33:06 +00:00
|
|
|
Action: func(cctx *cli.Context) error {
|
|
|
|
smapi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer closer()
|
|
|
|
|
2020-06-26 19:27:41 +00:00
|
|
|
if cctx.Bool("online") {
|
|
|
|
err = smapi.DealsSetConsiderOnlineRetrievalDeals(lcli.DaemonContext(cctx), false)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if cctx.Bool("offline") {
|
|
|
|
err = smapi.DealsSetConsiderOfflineRetrievalDeals(lcli.DaemonContext(cctx), false)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-06-26 17:33:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
2020-06-23 17:17:31 +00:00
|
|
|
},
|
|
|
|
}
|