Skip to content

Commit dfe50e4

Browse files
authored
Merge pull request #493 from yyforyongyu/db-params
liquidity: persist manager's params to disk
2 parents a4d343c + 2da3823 commit dfe50e4

File tree

14 files changed

+754
-451
lines changed

14 files changed

+754
-451
lines changed

cmd/loop/liquidity.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,12 @@ func setRule(ctx *cli.Context) error {
223223
}
224224

225225
var setParamsCommand = cli.Command{
226-
Name: "setparams",
227-
Usage: "update the parameters set for the liquidity manager",
228-
Description: "Updates the parameters set for the liquidity manager.",
226+
Name: "setparams",
227+
Usage: "update the parameters set for the liquidity manager",
228+
Description: "Updates the parameters set for the liquidity manager. " +
229+
"Note the parameters are persisted in db to save the trouble " +
230+
"of setting them again upon loopd restart. To get the " +
231+
"default values, use `getparams` before any `setparams`.",
229232
Flags: []cli.Flag{
230233
cli.IntFlag{
231234
Name: "sweeplimit",

liquidity/autoloop_testcontext_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ func newAutoloopTestCtx(t *testing.T, parameters Parameters,
166166
MinimumConfirmations: loop.DefaultSweepConfTarget,
167167
Lnd: &testCtx.lnd.LndServices,
168168
Clock: testCtx.testClock,
169+
PutLiquidityParams: func(_ []byte) error {
170+
return nil
171+
},
172+
FetchLiquidityParams: func() ([]byte, error) {
173+
return nil, nil
174+
},
169175
}
170176

171177
// SetParameters needs to make a call to our mocked restrictions call,
@@ -179,7 +185,7 @@ func newAutoloopTestCtx(t *testing.T, parameters Parameters,
179185
// Create a manager with our test config and set our starting set of
180186
// parameters.
181187
testCtx.manager = NewManager(cfg)
182-
err := testCtx.manager.SetParameters(context.Background(), parameters)
188+
err := testCtx.manager.setParameters(context.Background(), parameters)
183189
assert.NoError(t, err)
184190
<-done
185191
return testCtx

0 commit comments

Comments
 (0)