Skip to content

Commit f00329d

Browse files
committed
loopd: hide reservation manager behind flag.
1 parent 30acccb commit f00329d

File tree

3 files changed

+39
-31
lines changed

3 files changed

+39
-31
lines changed

loopd/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ type Config struct {
168168
TotalPaymentTimeout time.Duration `long:"totalpaymenttimeout" description:"The timeout to use for off-chain payments."`
169169
MaxPaymentRetries int `long:"maxpaymentretries" description:"The maximum number of times an off-chain payment may be retried."`
170170

171-
EnableExperimental bool `long:"experimental" description:"Enable experimental features: taproot HTLCs and MuSig2 loop out sweeps."`
171+
EnableExperimental bool `long:"experimental" description:"Enable experimental features: reservations"`
172172

173173
Lnd *lndConfig `group:"lnd" namespace:"lnd"`
174174

loopd/daemon.go

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -484,18 +484,20 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
484484
}
485485

486486
// Create the reservation rpc server.
487-
reservationStore := reservation.NewSQLStore(baseDb)
488-
reservationConfig := &reservation.Config{
489-
Store: reservationStore,
490-
Wallet: d.lnd.WalletKit,
491-
ChainNotifier: d.lnd.ChainNotifier,
492-
ReservationClient: reservationClient,
493-
FetchL402: swapClient.Server.FetchL402,
494-
}
487+
if d.cfg.EnableExperimental {
488+
reservationStore := reservation.NewSQLStore(baseDb)
489+
reservationConfig := &reservation.Config{
490+
Store: reservationStore,
491+
Wallet: d.lnd.WalletKit,
492+
ChainNotifier: d.lnd.ChainNotifier,
493+
ReservationClient: reservationClient,
494+
FetchL402: swapClient.Server.FetchL402,
495+
}
495496

496-
d.reservationManager = reservation.NewManager(
497-
reservationConfig,
498-
)
497+
d.reservationManager = reservation.NewManager(
498+
reservationConfig,
499+
)
500+
}
499501

500502
// Now finally fully initialize the swap client RPC server instance.
501503
d.swapClientServer = swapClientServer{
@@ -576,28 +578,30 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
576578
}()
577579

578580
// Start the reservation manager.
579-
d.wg.Add(1)
580-
go func() {
581-
defer d.wg.Done()
581+
if d.reservationManager != nil {
582+
d.wg.Add(1)
583+
go func() {
584+
defer d.wg.Done()
582585

583-
// We need to know the current block height to properly
584-
// initialize the reservation manager.
585-
getInfo, err := d.lnd.Client.GetInfo(d.mainCtx)
586-
if err != nil {
587-
d.internalErrChan <- err
588-
return
589-
}
586+
// We need to know the current block height to properly
587+
// initialize the reservation manager.
588+
getInfo, err := d.lnd.Client.GetInfo(d.mainCtx)
589+
if err != nil {
590+
d.internalErrChan <- err
591+
return
592+
}
590593

591-
log.Info("Starting reservation manager")
592-
defer log.Info("Reservation manager stopped")
594+
log.Info("Starting reservation manager")
595+
defer log.Info("Reservation manager stopped")
593596

594-
err = d.reservationManager.Run(
595-
d.mainCtx, int32(getInfo.BlockHeight),
596-
)
597-
if err != nil && !errors.Is(err, context.Canceled) {
598-
d.internalErrChan <- err
599-
}
600-
}()
597+
err = d.reservationManager.Run(
598+
d.mainCtx, int32(getInfo.BlockHeight),
599+
)
600+
if err != nil && !errors.Is(err, context.Canceled) {
601+
d.internalErrChan <- err
602+
}
603+
}()
604+
}
601605

602606
// Last, start our internal error handler. This will return exactly one
603607
// error or nil on the main error channel to inform the caller that

loopd/swapclient_server.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,10 @@ func (s *swapClientServer) ListReservations(ctx context.Context,
11451145
_ *clientrpc.ListReservationsRequest) (
11461146
*clientrpc.ListReservationsResponse, error) {
11471147

1148+
if s.reservationManager == nil {
1149+
return nil, status.Error(codes.Unimplemented,
1150+
"Restart loop with --experimental")
1151+
}
11481152
reservations, err := s.reservationManager.GetReservations(
11491153
ctx,
11501154
)

0 commit comments

Comments
 (0)