Skip to content

Commit e7e5121

Browse files
terminal: setup LND prior to stores
In the upcoming actions migration, we need fetch LNDs macaroons prior to initializing the stores, as the macaroons will be required during the migration. This requires that we setup the connection to LND before we initialize the stores, as we can only fetch the macaroons after the LND connection is established. This commit refactors the litd startup process, so that the stores are initialized after the LND connection is established.
1 parent f93d0ae commit e7e5121

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

terminal.go

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -447,22 +447,6 @@ func (g *LightningTerminal) start(ctx context.Context) error {
447447
return fmt.Errorf("could not create network directory: %v", err)
448448
}
449449

450-
g.stores, err = NewStores(g.cfg, clock.NewDefaultClock())
451-
if err != nil {
452-
return fmt.Errorf("could not create stores: %v", err)
453-
}
454-
455-
if err := g.stores.firewall.Start(ctx); err != nil {
456-
return fmt.Errorf("could not start firewall DB: %v", err)
457-
}
458-
459-
g.accountService, err = accounts.NewService(
460-
g.stores.accounts, accountServiceErrCallback,
461-
)
462-
if err != nil {
463-
return fmt.Errorf("error creating account service: %v", err)
464-
}
465-
466450
g.accountRpcServer = accounts.NewRPCServer()
467451

468452
g.ruleMgrs = rules.NewRuleManagerSet()
@@ -735,6 +719,27 @@ func (g *LightningTerminal) start(ctx context.Context) error {
735719
// lnd clients.
736720
g.statusMgr.SetRunning(subservers.LND)
737721

722+
g.stores, err = NewStores(g.cfg, clock.NewDefaultClock())
723+
if err != nil {
724+
return fmt.Errorf("could not create stores: %v", err)
725+
}
726+
727+
if err := g.stores.firewall.Start(ctx); err != nil {
728+
return fmt.Errorf("could not start firewall DB: %v", err)
729+
}
730+
731+
g.accountService, err = accounts.NewService(
732+
g.stores.accounts, accountServiceErrCallback,
733+
)
734+
if err != nil {
735+
return fmt.Errorf("error creating account service: %v", err)
736+
}
737+
738+
if err != nil {
739+
return fmt.Errorf("could not create new session rpc "+
740+
"server: %v", err)
741+
}
742+
738743
// Both connection types are ready now, let's start our sub-servers if
739744
// they should be started locally as an integrated service.
740745
createDefaultMacaroons := !g.cfg.statelessInitMode

0 commit comments

Comments
 (0)