2
0
mirror of https://github.com/lightninglabs/loop synced 2024-11-11 13:11:12 +00:00

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.
This commit is contained in:
carla 2020-09-30 12:34:11 +02:00
parent f23a527927
commit 8931fd370c
No known key found for this signature in database
GPG Key ID: 4CA7FE54A6213C91
2 changed files with 13 additions and 11 deletions

View File

@ -36,8 +36,8 @@ func getParams(ctx *cli.Context) error {
return nil return nil
} }
var setLiquidityParamCommand = cli.Command{ var setLiquidityRuleCommand = cli.Command{
Name: "setparam", Name: "setrule",
Usage: "set liquidity manager rule for a channel", Usage: "set liquidity manager rule for a channel",
Description: "Update or remove the liquidity rule for a channel.", Description: "Update or remove the liquidity rule for a channel.",
ArgsUsage: "shortchanid", ArgsUsage: "shortchanid",
@ -58,10 +58,10 @@ var setLiquidityParamCommand = cli.Command{
Usage: "remove the rule currently set for the channel.", 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. // We require that a channel ID is set for this rule update.
if ctx.NArg() != 1 { if ctx.NArg() != 1 {
return fmt.Errorf("please set a channel id for the rule " + return fmt.Errorf("please set a channel id for the rule " +
@ -122,12 +122,11 @@ func setParam(ctx *cli.Context) error {
"flag") "flag")
} }
params.Rules = otherRules
_, err = client.SetLiquidityParams( _, err = client.SetLiquidityParams(
context.Background(), context.Background(),
&looprpc.SetLiquidityParamsRequest{ &looprpc.SetLiquidityParamsRequest{
Parameters: &looprpc.LiquidityParameters{ Parameters: params,
Rules: otherRules,
},
}, },
) )
return err 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. // Update our parameters to the existing set, plus our new rule.
_, err = client.SetLiquidityParams( _, err = client.SetLiquidityParams(
context.Background(), context.Background(),
&looprpc.SetLiquidityParamsRequest{ &looprpc.SetLiquidityParamsRequest{
Parameters: &looprpc.LiquidityParameters{ Parameters: params,
Rules: append(otherRules, newRule),
},
}, },
) )

View File

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