Skip to content

Commit 7409ae7

Browse files
committed
loopd: add notification manager
This commit adds the notification manager to the loopd daemon.
1 parent 5df53cd commit 7409ae7

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"
@@ -501,21 +502,41 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
501502
}
502503
}
503504

505+
// Start the notification manager.
506+
notificationCfg := &notifications.Config{
507+
Client: loop_swaprpc.NewSwapServerClient(swapClient.Conn),
508+
FetchL402: swapClient.Server.FetchL402,
509+
}
510+
notificationManager := notifications.NewManager(notificationCfg)
511+
512+
d.wg.Add(1)
513+
go func() {
514+
defer d.wg.Done()
515+
516+
log.Info("Starting notification manager")
517+
err := notificationManager.Run(d.mainCtx)
518+
if err != nil {
519+
d.internalErrChan <- err
520+
log.Errorf("Notification manager stopped: %v", err)
521+
}
522+
}()
523+
504524
var (
505525
reservationManager *reservation.Manager
506526
instantOutManager *instantout.Manager
507527
)
528+
508529
// Create the reservation and instantout managers.
509530
if d.cfg.EnableExperimental {
510531
reservationStore := reservation.NewSQLStore(
511532
loopdb.NewTypedStore[reservation.Querier](baseDb),
512533
)
513534
reservationConfig := &reservation.Config{
514-
Store: reservationStore,
515-
Wallet: d.lnd.WalletKit,
516-
ChainNotifier: d.lnd.ChainNotifier,
517-
ReservationClient: reservationClient,
518-
FetchL402: swapClient.Server.FetchL402,
535+
Store: reservationStore,
536+
Wallet: d.lnd.WalletKit,
537+
ChainNotifier: d.lnd.ChainNotifier,
538+
ReservationClient: reservationClient,
539+
NotificationManager: notificationManager,
519540
}
520541

521542
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)