Skip to content

Commit

Permalink
Create lnd client each loop incase of blips
Browse files Browse the repository at this point in the history
  • Loading branch information
nyonson committed Sep 4, 2023
1 parent 2a7c80f commit 950bac5
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions cmd/raiju/raiju.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,26 +287,26 @@ func main() {

view.TableFees(f)

// periodically rebalance, don't panic in this routine since its best effort
// periodically rebalance
go func() {
cfg := &lndclient.LndServicesConfig{
LndAddress: *host,
Network: lndclient.Network(*network),
CustomMacaroonPath: *macPath,
TLSPath: *tlsPath,
RPCTimeout: rpcTimeout,
}
services, err := lndclient.NewLndServices(cfg)
if err != nil {
cmdLog.Printf("Unable to connect to lnd in order to rebalance %s", err)
return
}
defer services.Close()

c := lightning.NewLndClient(services, *network)
r := raiju.New(c, f)
for range time.Tick(time.Duration(12) * time.Hour) {
func() {
cfg := &lndclient.LndServicesConfig{
LndAddress: *host,
Network: lndclient.Network(*network),
CustomMacaroonPath: *macPath,
TLSPath: *tlsPath,
RPCTimeout: rpcTimeout,
}
services, err := lndclient.NewLndServices(cfg)
if err != nil {
cmdLog.Printf("Unable to connect to lnd in order to rebalance %s", err)
return
}
defer services.Close()

c := lightning.NewLndClient(services, *network)
r := raiju.New(c, f)
cmdLog.Println("Rebalancing channels...")
rebalanced, err := r.Rebalance(ctx, 5.0, f.RebalanceFee())
if err != nil {
Expand Down

0 comments on commit 950bac5

Please sign in to comment.