mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopd: hide reservation manager behind flag.
This commit is contained in:
parent
30acccbb6f
commit
f00329d7c7
3 changed files with 39 additions and 31 deletions
|
|
@ -168,7 +168,7 @@ type Config struct {
|
|||
TotalPaymentTimeout time.Duration `long:"totalpaymenttimeout" description:"The timeout to use for off-chain payments."`
|
||||
MaxPaymentRetries int `long:"maxpaymentretries" description:"The maximum number of times an off-chain payment may be retried."`
|
||||
|
||||
EnableExperimental bool `long:"experimental" description:"Enable experimental features: taproot HTLCs and MuSig2 loop out sweeps."`
|
||||
EnableExperimental bool `long:"experimental" description:"Enable experimental features: reservations"`
|
||||
|
||||
Lnd *lndConfig `group:"lnd" namespace:"lnd"`
|
||||
|
||||
|
|
|
|||
|
|
@ -484,18 +484,20 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
|
|||
}
|
||||
|
||||
// Create the reservation rpc server.
|
||||
reservationStore := reservation.NewSQLStore(baseDb)
|
||||
reservationConfig := &reservation.Config{
|
||||
Store: reservationStore,
|
||||
Wallet: d.lnd.WalletKit,
|
||||
ChainNotifier: d.lnd.ChainNotifier,
|
||||
ReservationClient: reservationClient,
|
||||
FetchL402: swapClient.Server.FetchL402,
|
||||
}
|
||||
if d.cfg.EnableExperimental {
|
||||
reservationStore := reservation.NewSQLStore(baseDb)
|
||||
reservationConfig := &reservation.Config{
|
||||
Store: reservationStore,
|
||||
Wallet: d.lnd.WalletKit,
|
||||
ChainNotifier: d.lnd.ChainNotifier,
|
||||
ReservationClient: reservationClient,
|
||||
FetchL402: swapClient.Server.FetchL402,
|
||||
}
|
||||
|
||||
d.reservationManager = reservation.NewManager(
|
||||
reservationConfig,
|
||||
)
|
||||
d.reservationManager = reservation.NewManager(
|
||||
reservationConfig,
|
||||
)
|
||||
}
|
||||
|
||||
// Now finally fully initialize the swap client RPC server instance.
|
||||
d.swapClientServer = swapClientServer{
|
||||
|
|
@ -576,28 +578,30 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
|
|||
}()
|
||||
|
||||
// Start the reservation manager.
|
||||
d.wg.Add(1)
|
||||
go func() {
|
||||
defer d.wg.Done()
|
||||
if d.reservationManager != nil {
|
||||
d.wg.Add(1)
|
||||
go func() {
|
||||
defer d.wg.Done()
|
||||
|
||||
// We need to know the current block height to properly
|
||||
// initialize the reservation manager.
|
||||
getInfo, err := d.lnd.Client.GetInfo(d.mainCtx)
|
||||
if err != nil {
|
||||
d.internalErrChan <- err
|
||||
return
|
||||
}
|
||||
// We need to know the current block height to properly
|
||||
// initialize the reservation manager.
|
||||
getInfo, err := d.lnd.Client.GetInfo(d.mainCtx)
|
||||
if err != nil {
|
||||
d.internalErrChan <- err
|
||||
return
|
||||
}
|
||||
|
||||
log.Info("Starting reservation manager")
|
||||
defer log.Info("Reservation manager stopped")
|
||||
log.Info("Starting reservation manager")
|
||||
defer log.Info("Reservation manager stopped")
|
||||
|
||||
err = d.reservationManager.Run(
|
||||
d.mainCtx, int32(getInfo.BlockHeight),
|
||||
)
|
||||
if err != nil && !errors.Is(err, context.Canceled) {
|
||||
d.internalErrChan <- err
|
||||
}
|
||||
}()
|
||||
err = d.reservationManager.Run(
|
||||
d.mainCtx, int32(getInfo.BlockHeight),
|
||||
)
|
||||
if err != nil && !errors.Is(err, context.Canceled) {
|
||||
d.internalErrChan <- err
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// Last, start our internal error handler. This will return exactly one
|
||||
// error or nil on the main error channel to inform the caller that
|
||||
|
|
|
|||
|
|
@ -1145,6 +1145,10 @@ func (s *swapClientServer) ListReservations(ctx context.Context,
|
|||
_ *clientrpc.ListReservationsRequest) (
|
||||
*clientrpc.ListReservationsResponse, error) {
|
||||
|
||||
if s.reservationManager == nil {
|
||||
return nil, status.Error(codes.Unimplemented,
|
||||
"Restart loop with --experimental")
|
||||
}
|
||||
reservations, err := s.reservationManager.GetReservations(
|
||||
ctx,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue