loop: rename setparam command to setrule

As we add more paramters to the liqudity manager, it will become more
difficult to include them in a single cli endpoint with rules. This
commit renames the existing setparam command (which is only used for
rules at present), so that we can have a dedicated paramters cli
command for all the new values we are adding.
pull/289/head
carla 4 years ago
parent f23a527927
commit 8931fd370c
No known key found for this signature in database
GPG Key ID: 4CA7FE54A6213C91

@ -36,8 +36,8 @@ func getParams(ctx *cli.Context) error {
return nil
}
var setLiquidityParamCommand = cli.Command{
Name: "setparam",
var setLiquidityRuleCommand = cli.Command{
Name: "setrule",
Usage: "set liquidity manager rule for a channel",
Description: "Update or remove the liquidity rule for a channel.",
ArgsUsage: "shortchanid",
@ -58,10 +58,10 @@ var setLiquidityParamCommand = cli.Command{
Usage: "remove the rule currently set for the channel.",
},
},
Action: setParam,
Action: setRule,
}
func setParam(ctx *cli.Context) error {
func setRule(ctx *cli.Context) error {
// We require that a channel ID is set for this rule update.
if ctx.NArg() != 1 {
return fmt.Errorf("please set a channel id for the rule " +
@ -122,12 +122,11 @@ func setParam(ctx *cli.Context) error {
"flag")
}
params.Rules = otherRules
_, err = client.SetLiquidityParams(
context.Background(),
&looprpc.SetLiquidityParamsRequest{
Parameters: &looprpc.LiquidityParameters{
Rules: otherRules,
},
Parameters: params,
},
)
return err
@ -158,13 +157,16 @@ func setParam(ctx *cli.Context) error {
)
}
// Just set the rules on our current set of parameters and leave the
// other values untouched.
otherRules = append(otherRules, newRule)
params.Rules = otherRules
// Update our parameters to the existing set, plus our new rule.
_, err = client.SetLiquidityParams(
context.Background(),
&looprpc.SetLiquidityParamsRequest{
Parameters: &looprpc.LiquidityParameters{
Rules: append(otherRules, newRule),
},
Parameters: params,
},
)

@ -129,7 +129,7 @@ func main() {
loopOutCommand, loopInCommand, termsCommand,
monitorCommand, quoteCommand, listAuthCommand,
listSwapsCommand, swapInfoCommand, getLiquidityParamsCommand,
setLiquidityParamCommand, suggestSwapCommand,
setLiquidityRuleCommand, suggestSwapCommand,
}
err := app.Run(os.Args)

Loading…
Cancel
Save