add client command for mpool config
This commit is contained in:
parent
9a23ede4fd
commit
054fc4a614
46
cli/mpool.go
46
cli/mpool.go
@ -24,6 +24,7 @@ var mpoolCmd = &cli.Command{
|
|||||||
mpoolStat,
|
mpoolStat,
|
||||||
mpoolReplaceCmd,
|
mpoolReplaceCmd,
|
||||||
mpoolFindCmd,
|
mpoolFindCmd,
|
||||||
|
mpoolConfig,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,3 +416,48 @@ var mpoolFindCmd = &cli.Command{
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var mpoolConfig = &cli.Command{
|
||||||
|
Name: "config",
|
||||||
|
Usage: "get or set current mpool configuration",
|
||||||
|
ArgsUsage: "[new-config]",
|
||||||
|
Action: func(cctx *cli.Context) error {
|
||||||
|
if cctx.Args().Len() > 1 {
|
||||||
|
return cli.ShowCommandHelp(cctx, cctx.Command.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
api, closer, err := GetFullNodeAPI(cctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer closer()
|
||||||
|
|
||||||
|
ctx := ReqContext(cctx)
|
||||||
|
|
||||||
|
if cctx.Args().Len() == 0 {
|
||||||
|
cfg, err := api.MpoolGetConfig(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
bytes, err := json.Marshal(cfg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(string(bytes))
|
||||||
|
} else {
|
||||||
|
cfg := new(types.MpoolConfig)
|
||||||
|
bytes := []byte(cctx.Args().Get(0))
|
||||||
|
|
||||||
|
err := json.Unmarshal(bytes, cfg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return api.MpoolSetConfig(ctx, cfg)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user