Skip to content

Commit

Permalink
loopd: add notification manager
Browse files Browse the repository at this point in the history
This commit adds the notification manager to the
loopd daemon.
  • Loading branch information
sputn1ck committed Oct 8, 2024
1 parent 5df53cd commit 7409ae7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
31 changes: 26 additions & 5 deletions loopd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/lightninglabs/loop/loopd/perms"
"github.com/lightninglabs/loop/loopdb"
loop_looprpc "github.com/lightninglabs/loop/looprpc"
"github.com/lightninglabs/loop/notifications"
loop_swaprpc "github.com/lightninglabs/loop/swapserverrpc"
"github.com/lightninglabs/loop/sweepbatcher"
"github.com/lightningnetwork/lnd/clock"
Expand Down Expand Up @@ -501,21 +502,41 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
}
}

// Start the notification manager.
notificationCfg := &notifications.Config{
Client: loop_swaprpc.NewSwapServerClient(swapClient.Conn),
FetchL402: swapClient.Server.FetchL402,
}
notificationManager := notifications.NewManager(notificationCfg)

d.wg.Add(1)
go func() {
defer d.wg.Done()

log.Info("Starting notification manager")
err := notificationManager.Run(d.mainCtx)
if err != nil {
d.internalErrChan <- err
log.Errorf("Notification manager stopped: %v", err)
}
}()

var (
reservationManager *reservation.Manager
instantOutManager *instantout.Manager
)

// Create the reservation and instantout managers.
if d.cfg.EnableExperimental {
reservationStore := reservation.NewSQLStore(
loopdb.NewTypedStore[reservation.Querier](baseDb),
)
reservationConfig := &reservation.Config{
Store: reservationStore,
Wallet: d.lnd.WalletKit,
ChainNotifier: d.lnd.ChainNotifier,
ReservationClient: reservationClient,
FetchL402: swapClient.Server.FetchL402,
Store: reservationStore,
Wallet: d.lnd.WalletKit,
ChainNotifier: d.lnd.ChainNotifier,
ReservationClient: reservationClient,
NotificationManager: notificationManager,
}

reservationManager = reservation.NewManager(
Expand Down
4 changes: 4 additions & 0 deletions loopd/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/lightninglabs/loop/instantout/reservation"
"github.com/lightninglabs/loop/liquidity"
"github.com/lightninglabs/loop/loopdb"
"github.com/lightninglabs/loop/notifications"
"github.com/lightninglabs/loop/sweepbatcher"
"github.com/lightningnetwork/lnd"
"github.com/lightningnetwork/lnd/build"
Expand Down Expand Up @@ -48,6 +49,9 @@ func SetupLoggers(root *build.RotatingLogWriter, intercept signal.Interceptor) {
lnd.AddSubLogger(
root, instantout.Subsystem, intercept, instantout.UseLogger,
)
lnd.AddSubLogger(
root, notifications.Subsystem, intercept, notifications.UseLogger,
)
}

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

0 comments on commit 7409ae7

Please sign in to comment.