discovery: pass context to ProcessRemoteAnnouncement

With this, we move a context.TODO() out of the gossiper and into the
brontide package - this will be removed in a future PR which focuses on
threading contexts through that code.
This commit is contained in:
Elle Mouton
2025-04-07 11:13:01 +02:00
parent 69e9ce9b24
commit f4b7cc4f4b
4 changed files with 431 additions and 353 deletions

View File

@@ -857,10 +857,8 @@ func (d *AuthenticatedGossiper) stop() {
// then added to a queue for batched trickled announcement to all connected
// peers. Remote channel announcements should contain the announcement proof
// and be fully validated.
func (d *AuthenticatedGossiper) ProcessRemoteAnnouncement(msg lnwire.Message,
peer lnpeer.Peer) chan error {
ctx := context.TODO()
func (d *AuthenticatedGossiper) ProcessRemoteAnnouncement(ctx context.Context,
msg lnwire.Message, peer lnpeer.Peer) chan error {
log.Debugf("Processing remote msg %T from peer=%x", msg, peer.PubKey())
@@ -950,8 +948,12 @@ func (d *AuthenticatedGossiper) ProcessRemoteAnnouncement(msg lnwire.Message,
// If the peer that sent us this error is quitting, then we don't need
// to send back an error and can return immediately.
// TODO(elle): the peer should now just rely on canceling the passed
// context.
case <-peer.QuitSignal():
return nil
case <-ctx.Done():
return nil
case <-d.quit:
nMsg.err <- ErrGossiperShuttingDown
}