2019-10-04 19:55:33 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
2019-12-11 02:06:28 +00:00
|
|
|
"github.com/docker/go-units"
|
2020-06-02 18:12:53 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
2020-06-05 22:59:01 +00:00
|
|
|
"golang.org/x/xerrors"
|
2020-01-08 20:31:35 +00:00
|
|
|
|
2022-06-14 15:00:51 +00:00
|
|
|
paramfetch "github.com/filecoin-project/go-paramfetch"
|
|
|
|
|
2020-01-08 20:31:35 +00:00
|
|
|
"github.com/filecoin-project/lotus/build"
|
2019-10-04 19:55:33 +00:00
|
|
|
)
|
|
|
|
|
2021-03-23 23:27:34 +00:00
|
|
|
var FetchParamCmd = &cli.Command{
|
2020-06-12 05:13:11 +00:00
|
|
|
Name: "fetch-params",
|
|
|
|
Usage: "Fetch proving parameters",
|
|
|
|
ArgsUsage: "[sectorSize]",
|
2019-10-04 19:55:33 +00:00
|
|
|
Action: func(cctx *cli.Context) error {
|
2020-06-12 05:13:11 +00:00
|
|
|
if !cctx.Args().Present() {
|
|
|
|
return xerrors.Errorf("must pass sector size to fetch params for (specify as \"32GiB\", for instance)")
|
|
|
|
}
|
|
|
|
sectorSizeInt, err := units.RAMInBytes(cctx.Args().First())
|
2019-12-11 02:06:28 +00:00
|
|
|
if err != nil {
|
2020-06-12 05:13:11 +00:00
|
|
|
return xerrors.Errorf("error parsing sector size (specify as \"32GiB\", for instance): %w", err)
|
2019-12-11 02:06:28 +00:00
|
|
|
}
|
|
|
|
sectorSize := uint64(sectorSizeInt)
|
2020-06-05 17:19:33 +00:00
|
|
|
|
2021-03-10 15:16:44 +00:00
|
|
|
err = paramfetch.GetParams(ReqContext(cctx), build.ParametersJSON(), build.SrsJSON(), sectorSize)
|
2019-11-14 01:15:33 +00:00
|
|
|
if err != nil {
|
2019-10-04 19:55:33 +00:00
|
|
|
return xerrors.Errorf("fetching proof parameters: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|