Skip to content

Commit 1f3c9af

Browse files
committed
loopd: add notification manager
This commit adds the notification manager to the loopd daemon.
1 parent 2000bae commit 1f3c9af

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

loopd/daemon.go

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/lightninglabs/loop/loopd/perms"
2222
"github.com/lightninglabs/loop/loopdb"
2323
loop_looprpc "github.com/lightninglabs/loop/looprpc"
24+
"github.com/lightninglabs/loop/notifications"
2425
loop_swaprpc "github.com/lightninglabs/loop/swapserverrpc"
2526
"github.com/lightninglabs/loop/sweepbatcher"
2627
"github.com/lightningnetwork/lnd/clock"
@@ -498,21 +499,41 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
498499
}
499500
}
500501

502+
// Start the notification manager.
503+
notificationCfg := &notifications.Config{
504+
Client: loop_swaprpc.NewSwapServerClient(swapClient.Conn),
505+
FetchL402: swapClient.Server.FetchL402,
506+
}
507+
notificationManager := notifications.NewManager(notificationCfg)
508+
509+
d.wg.Add(1)
510+
go func() {
511+
defer d.wg.Done()
512+
513+
log.Info("Starting notification manager")
514+
err := notificationManager.Run(d.mainCtx)
515+
if err != nil {
516+
d.internalErrChan <- err
517+
log.Errorf("Notification manager stopped: %v", err)
518+
}
519+
}()
520+
501521
var (
502522
reservationManager *reservation.Manager
503523
instantOutManager *instantout.Manager
504524
)
525+
505526
// Create the reservation and instantout managers.
506527
if d.cfg.EnableExperimental {
507528
reservationStore := reservation.NewSQLStore(
508529
loopdb.NewTypedStore[reservation.Querier](baseDb),
509530
)
510531
reservationConfig := &reservation.Config{
511-
Store: reservationStore,
512-
Wallet: d.lnd.WalletKit,
513-
ChainNotifier: d.lnd.ChainNotifier,
514-
ReservationClient: reservationClient,
515-
FetchL402: swapClient.Server.FetchL402,
532+
Store: reservationStore,
533+
Wallet: d.lnd.WalletKit,
534+
ChainNotifier: d.lnd.ChainNotifier,
535+
ReservationClient: reservationClient,
536+
NotificationManager: notificationManager,
516537
}
517538

518539
reservationManager = reservation.NewManager(

loopd/log.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/lightninglabs/loop/instantout/reservation"
1111
"github.com/lightninglabs/loop/liquidity"
1212
"github.com/lightninglabs/loop/loopdb"
13+
"github.com/lightninglabs/loop/notifications"
1314
"github.com/lightninglabs/loop/sweepbatcher"
1415
"github.com/lightningnetwork/lnd"
1516
"github.com/lightningnetwork/lnd/build"
@@ -48,6 +49,9 @@ func SetupLoggers(root *build.RotatingLogWriter, intercept signal.Interceptor) {
4849
lnd.AddSubLogger(
4950
root, instantout.Subsystem, intercept, instantout.UseLogger,
5051
)
52+
lnd.AddSubLogger(
53+
root, notifications.Subsystem, intercept, notifications.UseLogger,
54+
)
5155
}
5256

5357
// genSubLogger creates a logger for a subsystem. We provide an instance of

0 commit comments

Comments
 (0)