From eadce0a1ecd0c7da0a1745ec0534f29264728511 Mon Sep 17 00:00:00 2001 From: Nick Johnson Date: Thu, 13 Apr 2023 12:24:43 -0700 Subject: [PATCH] Simplify RebalanceAll interface --- README.md | 2 +- cmd/raiju/raiju.go | 2 +- raiju.go | 4 ++-- raiju_test.go | 4 +--- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 42e6bbb..024cfde 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ # dashboard -`raiju`'s root command, `raiju`, fires up an interactive TUI dashboard. +`raiju`'s root command, `raiju`, fires up an interactive TUI dashboard which uses the subcommands under the hood. # subcommands diff --git a/cmd/raiju/raiju.go b/cmd/raiju/raiju.go index ecf65a3..73fd9b9 100644 --- a/cmd/raiju/raiju.go +++ b/cmd/raiju/raiju.go @@ -286,7 +286,7 @@ func main() { cmdLog.Printf("rebalanced %f percent with a %d sat fee\n", percent, fee) } else { cmdLog.Println("Rebalancing all channels...") - rebalanced, err := r.RebalanceAll(ctx, stepPercent, maxPercent, maxFee) + rebalanced, err := r.RebalanceAll(ctx, stepPercent, maxPercent) if err != nil { return err } diff --git a/raiju.go b/raiju.go index 84c177a..9b66cd5 100644 --- a/raiju.go +++ b/raiju.go @@ -350,7 +350,7 @@ func (r Raiju) Rebalance(ctx context.Context, outChannelID lightning.ChannelID, } // RebalanceAll high local liquidity channels into low liquidity channels, return percent rebalanced per channel attempted. -func (r Raiju) RebalanceAll(ctx context.Context, stepPercent float64, maxPercent float64, maxFee lightning.FeePPM) (map[lightning.ChannelID]float64, error) { +func (r Raiju) RebalanceAll(ctx context.Context, stepPercent float64, maxPercent float64) (map[lightning.ChannelID]float64, error) { local, err := r.l.GetInfo(ctx) if err != nil { return map[lightning.ChannelID]float64{}, err @@ -394,7 +394,7 @@ func (r Raiju) RebalanceAll(ctx context.Context, stepPercent float64, maxPercent } potentialLocal := lightning.Satoshi(float64(h.Capacity) * maxPercent) if r.f.PotentialFee(ul, potentialLocal) != r.f.Fee(ul) { - p, f, err := r.Rebalance(ctx, h.ChannelID, lastHopPubkey, stepPercent, (maxPercent - percentRebalanced), maxFee) + p, f, err := r.Rebalance(ctx, h.ChannelID, lastHopPubkey, stepPercent, (maxPercent - percentRebalanced), r.f.RebalanceFee()) if err != nil { return map[lightning.ChannelID]float64{}, err } diff --git a/raiju_test.go b/raiju_test.go index 0990186..5ce67ec 100644 --- a/raiju_test.go +++ b/raiju_test.go @@ -712,7 +712,6 @@ func TestRaiju_RebalanceAll(t *testing.T) { ctx context.Context stepPercent float64 maxPercent float64 - maxFee lightning.FeePPM } tests := []struct { name string @@ -753,7 +752,6 @@ func TestRaiju_RebalanceAll(t *testing.T) { args: args{ stepPercent: 1, maxPercent: 5, - maxFee: 10, }, want: map[lightning.ChannelID]float64{}, wantErr: false, @@ -764,7 +762,7 @@ func TestRaiju_RebalanceAll(t *testing.T) { r := Raiju{ l: tt.fields.l, } - got, err := r.RebalanceAll(tt.args.ctx, tt.args.stepPercent, tt.args.maxPercent, tt.args.maxFee) + got, err := r.RebalanceAll(tt.args.ctx, tt.args.stepPercent, tt.args.maxPercent) if (err != nil) != tt.wantErr { t.Errorf("Raiju.RebalanceAll() error = %v, wantErr %v", err, tt.wantErr) }