Skip to content

Commit 9c861dc

Browse files
committed
loopd: add hyperloop manager
1 parent 98f853e commit 9c861dc

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

loopd/daemon.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
proxy "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
1717
"github.com/lightninglabs/lndclient"
1818
"github.com/lightninglabs/loop"
19+
"github.com/lightninglabs/loop/hyperloop"
1920
"github.com/lightninglabs/loop/instantout"
2021
"github.com/lightninglabs/loop/instantout/reservation"
2122
"github.com/lightninglabs/loop/loopd/perms"
@@ -450,6 +451,11 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
450451
swapClient.Conn,
451452
)
452453

454+
// Create a hyperloop server client.
455+
hyperloopClient := loop_swaprpc.NewHyperloopServerClient(
456+
swapClient.Conn,
457+
)
458+
453459
// Both the client RPC server and the swap server client should stop
454460
// on main context cancel. So we create it early and pass it down.
455461
d.mainCtx, d.mainCtxCancel = context.WithCancel(context.Background())
@@ -529,6 +535,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
529535
var (
530536
reservationManager *reservation.Manager
531537
instantOutManager *instantout.Manager
538+
hyperloopManager *hyperloop.Manager
532539
)
533540

534541
// Create the reservation and instantout managers.
@@ -569,6 +576,15 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
569576
instantOutManager = instantout.NewInstantOutManager(
570577
instantOutConfig,
571578
)
579+
580+
hyperloopConfig := &hyperloop.Config{
581+
Wallet: d.lnd.WalletKit,
582+
ChainNotifier: d.lnd.ChainNotifier,
583+
Signer: d.lnd.Signer,
584+
Router: d.lnd.Router,
585+
HyperloopClient: hyperloopClient,
586+
}
587+
hyperloopManager = hyperloop.NewManager(hyperloopConfig)
572588
}
573589

574590
// Now finally fully initialize the swap client RPC server instance.
@@ -584,6 +600,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
584600
mainCtx: d.mainCtx,
585601
reservationManager: reservationManager,
586602
instantOutManager: instantOutManager,
603+
hyperloopManager: hyperloopManager,
587604
}
588605

589606
// Retrieve all currently existing swaps from the database.
@@ -728,6 +745,23 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
728745
}
729746
}
730747

748+
// Start the hyperloop manager.
749+
if d.hyperloopManager != nil {
750+
d.wg.Add(1)
751+
go func() {
752+
defer d.wg.Done()
753+
754+
log.Info("Starting hyperloop manager")
755+
defer log.Info("Hyperloop manager stopped")
756+
757+
err := d.hyperloopManager.Run(d.mainCtx)
758+
if err != nil && !errors.Is(err, context.Canceled) {
759+
log.Errorf("Error running hyperloop manager: %v", err)
760+
d.internalErrChan <- err
761+
}
762+
}()
763+
}
764+
731765
// Last, start our internal error handler. This will return exactly one
732766
// error or nil on the main error channel to inform the caller that
733767
// something went wrong or that shutdown is complete. We don't add to

0 commit comments

Comments
 (0)