lnd: pass context to newServer and server.Start
In preparation for starting to thread a single parent context through LND, we update the main `server.Start` method to take a context so that it can later pass it to any subsytem's Start method it calls. We also pass the context to `newServer` since it makes some calls that will eventually reach the DB (for example the graph db).
This commit is contained in:
2 files changed
+6
-4
No files matched your search
@@ -626,7 +626,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg,
|
|||||||
// Set up the core server which will listen for incoming peer
|
// Set up the core server which will listen for incoming peer
|
||||||
// connections.
|
// connections.
|
||||||
server, err := newServer(
|
server, err := newServer(
|
||||||
cfg, cfg.Listeners, dbs, activeChainControl, &idKeyDesc,
|
ctx, cfg, cfg.Listeners, dbs, activeChainControl, &idKeyDesc,
|
||||||
activeChainControl.Cfg.WalletUnlockParams.ChansToRestore,
|
activeChainControl.Cfg.WalletUnlockParams.ChansToRestore,
|
||||||
multiAcceptor, torController, tlsManager, leaderElector,
|
multiAcceptor, torController, tlsManager, leaderElector,
|
||||||
implCfg,
|
implCfg,
|
||||||
@@ -758,7 +758,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg,
|
|||||||
// case the startup of the subservers do not behave as expected.
|
// case the startup of the subservers do not behave as expected.
|
||||||
errChan := make(chan error)
|
errChan := make(chan error)
|
||||||
go func() {
|
go func() {
|
||||||
errChan <- server.Start()
|
errChan <- server.Start(ctx)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|||||||
@@ -554,7 +554,9 @@ func noiseDial(idKey keychain.SingleKeyECDH,
|
|||||||
|
|
||||||
// newServer creates a new instance of the server which is to listen using the
|
// newServer creates a new instance of the server which is to listen using the
|
||||||
// passed listener address.
|
// passed listener address.
|
||||||
func newServer(cfg *Config, listenAddrs []net.Addr,
|
//
|
||||||
|
//nolint:funlen
|
||||||
|
func newServer(_ context.Context, cfg *Config, listenAddrs []net.Addr,
|
||||||
dbs *DatabaseInstances, cc *chainreg.ChainControl,
|
dbs *DatabaseInstances, cc *chainreg.ChainControl,
|
||||||
nodeKeyDesc *keychain.KeyDescriptor,
|
nodeKeyDesc *keychain.KeyDescriptor,
|
||||||
chansToRestore walletunlocker.ChannelsToRecover,
|
chansToRestore walletunlocker.ChannelsToRecover,
|
||||||
@@ -2217,7 +2219,7 @@ func (s *server) startLowLevelServices() error {
|
|||||||
// NOTE: This function is safe for concurrent access.
|
// NOTE: This function is safe for concurrent access.
|
||||||
//
|
//
|
||||||
//nolint:funlen
|
//nolint:funlen
|
||||||
func (s *server) Start() error {
|
func (s *server) Start(_ context.Context) error {
|
||||||
// Get the current blockbeat.
|
// Get the current blockbeat.
|
||||||
beat, err := s.getStartingBeat()
|
beat, err := s.getStartingBeat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in new issue
Block a user