Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opt: Adjust size flag to string type #6102

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions cmd/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
cmds "github.com/ipfs/go-ipfs-cmds"
"github.com/pkg/errors"

"github.com/docker/go-units"
paramfetch "github.com/filecoin-project/go-paramfetch"

"github.com/filecoin-project/venus/fixtures/assets"
)

Expand All @@ -14,11 +14,11 @@ var fetchCmd = &cmds.Command{
Tagline: "fetch paramsters",
},
Options: []cmds.Option{
cmds.Uint64Option(Size, "size to fetch"),
cmds.StringOption(Size, "size to fetch, eg. 2Kib,512Mib,32Gib,64Gib"),
},
Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
// highest precedence is cmd line flag.
if size, ok := req.Options[Size].(uint64); ok {
if sizeStr, ok := req.Options[Size].(string); ok {
ps, err := assets.GetProofParams()
if err != nil {
return err
Expand All @@ -29,7 +29,12 @@ var fetchCmd = &cmds.Command{
return err
}

if err := paramfetch.GetParams(req.Context, ps, srs, size); err != nil {
size, err := units.RAMInBytes(sizeStr)
if err != nil {
return err
}

if err := paramfetch.GetParams(req.Context, ps, srs, uint64(size)); err != nil {
return errors.Wrapf(err, "fetching proof parameters: %v", err)
}
return nil
Expand Down