Skip to content

Commit dbf6fe0

Browse files
authored
Merge pull request #559 from GeorgeTsagk/autoloop-parse-old-budget
Autoloop parse old budget to new parameters
2 parents e34653e + 55c769e commit dbf6fe0

File tree

4 files changed

+234
-185
lines changed

4 files changed

+234
-185
lines changed

liquidity/parameters.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ var (
3434
}
3535
)
3636

37+
const InfiniteDuration = (24 * 31 * 12 * 100) * time.Hour
38+
3739
// Parameters is a set of parameters provided by the user which guide
3840
// how we assess liquidity.
3941
type Parameters struct {
@@ -404,6 +406,18 @@ func RpcToParameters(req *clientrpc.LiquidityParameters) (*Parameters,
404406
time.Second
405407
}
406408

409+
// If an old-style budget was written to storage then express it by
410+
// using the new auto budget parameters. If the newly added parameters
411+
// have the 0 default value, but a budget was defined that means the
412+
// client is using the old style budget parameters.
413+
if req.AutoloopBudgetRefreshPeriodSec == 0 &&
414+
req.AutoloopBudgetSat != 0 {
415+
416+
params.AutoFeeRefreshPeriod = InfiniteDuration
417+
params.AutoloopBudgetLastRefresh = time.Unix(
418+
int64(req.AutoloopBudgetStartSec), 0)
419+
}
420+
407421
for _, rule := range req.Rules {
408422
peerRule := rule.Pubkey != nil
409423
chanRule := rule.ChannelId != 0

0 commit comments

Comments
 (0)