discovery: thread context through to gossiper

Pass the parent LND context to the gossiper, let it derive a child
context that gets cancelled on Stop. Pass the context through to any
methods that will eventually thread it through to any graph DB calls.

One `context.TODO()` is added here - this will be removed in the next
commit.

NOTE: for any internal methods that the context gets passed to, if those
methods already listen on the gossiper's `quit` channel, then then don't
need to also listen on the passed context's Done() channel because the
quit channel is closed at the same time that the context is cancelled.
This commit is contained in:
Elle Mouton committed 2025-05-22 14:14:36 +02:00
1 parent 53ba229436
commit 7fd453f319
3 files changed
+85 -58

No files matched your search

+2 -2
View File
@@ -2219,7 +2219,7 @@ func (s *server) startLowLevelServices() error {
// NOTE: This function is safe for concurrent access.
//
//nolint:funlen
func (s *server) Start(_ context.Context) error {
func (s *server) Start(ctx context.Context) error {
// Get the current blockbeat.
beat, err := s.getStartingBeat()
if err != nil {
@@ -2390,7 +2390,7 @@ func (s *server) Start(_ context.Context) error {
// The authGossiper depends on the chanRouter and therefore
// should be started after it.
cleanup = cleanup.add(s.authGossiper.Stop)
if err := s.authGossiper.Start(); err != nil {
if err := s.authGossiper.Start(ctx); err != nil {
startErr = err
return
}