From 8931fd370c4953fb94b901c48cf82b37e1075b5b Mon Sep 17 00:00:00 2001 From: carla Date: Wed, 30 Sep 2020 12:34:11 +0200 Subject: [PATCH] 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. --- cmd/loop/liquidity.go | 22 ++++++++++++---------- cmd/loop/main.go | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/cmd/loop/liquidity.go b/cmd/loop/liquidity.go index c382d7e..30716f1 100644 --- a/cmd/loop/liquidity.go +++ b/cmd/loop/liquidity.go @@ -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, }, ) diff --git a/cmd/loop/main.go b/cmd/loop/main.go index 97d33cd..9749306 100644 --- a/cmd/loop/main.go +++ b/cmd/loop/main.go @@ -129,7 +129,7 @@ func main() { loopOutCommand, loopInCommand, termsCommand, monitorCommand, quoteCommand, listAuthCommand, listSwapsCommand, swapInfoCommand, getLiquidityParamsCommand, - setLiquidityParamCommand, suggestSwapCommand, + setLiquidityRuleCommand, suggestSwapCommand, } err := app.Run(os.Args)