diff --git a/cmd/fetch.go b/cmd/fetch.go index 09d5d8af20..12209aa182 100644 --- a/cmd/fetch.go +++ b/cmd/fetch.go @@ -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" ) @@ -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 @@ -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