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:
4 files changed
+431
-353
No files matched your search
@@ -857,10 +857,8 @@ func (d *AuthenticatedGossiper) stop() {
|
|||||||
// then added to a queue for batched trickled announcement to all connected
|
// then added to a queue for batched trickled announcement to all connected
|
||||||
// peers. Remote channel announcements should contain the announcement proof
|
// peers. Remote channel announcements should contain the announcement proof
|
||||||
// and be fully validated.
|
// and be fully validated.
|
||||||
func (d *AuthenticatedGossiper) ProcessRemoteAnnouncement(msg lnwire.Message,
|
func (d *AuthenticatedGossiper) ProcessRemoteAnnouncement(ctx context.Context,
|
||||||
peer lnpeer.Peer) chan error {
|
msg lnwire.Message, peer lnpeer.Peer) chan error {
|
||||||
|
|
||||||
ctx := context.TODO()
|
|
||||||
|
|
||||||
log.Debugf("Processing remote msg %T from peer=%x", msg, peer.PubKey())
|
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
|
// If the peer that sent us this error is quitting, then we don't need
|
||||||
// to send back an error and can return immediately.
|
// 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():
|
case <-peer.QuitSignal():
|
||||||
return nil
|
return nil
|
||||||
|
case <-ctx.Done():
|
||||||
|
return nil
|
||||||
case <-d.quit:
|
case <-d.quit:
|
||||||
nMsg.err <- ErrGossiperShuttingDown
|
nMsg.err <- ErrGossiperShuttingDown
|
||||||
}
|
}
|
||||||
|
|||||||
+419
-347
File diff suppressed because it is too large.
Load diff
@@ -454,7 +454,7 @@ func TestGossipSyncerApplyNoHistoricalGossipFilter(t *testing.T) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// We'll now attempt to apply the gossip filter for the remote peer.
|
// We'll now attempt to apply the gossip filter for the remote peer.
|
||||||
syncer.ApplyGossipFilter(ctx, remoteHorizon)
|
require.NoError(t, syncer.ApplyGossipFilter(ctx, remoteHorizon))
|
||||||
|
|
||||||
// Ensure that the syncer's remote horizon was properly updated.
|
// Ensure that the syncer's remote horizon was properly updated.
|
||||||
if !reflect.DeepEqual(syncer.remoteUpdateHorizon, remoteHorizon) {
|
if !reflect.DeepEqual(syncer.remoteUpdateHorizon, remoteHorizon) {
|
||||||
|
|||||||
+5
-1
@@ -1989,9 +1989,13 @@ func newChanMsgStream(p *Brontide, cid lnwire.ChannelID) *msgStream {
|
|||||||
// channel announcements.
|
// channel announcements.
|
||||||
func newDiscMsgStream(p *Brontide) *msgStream {
|
func newDiscMsgStream(p *Brontide) *msgStream {
|
||||||
apply := func(msg lnwire.Message) {
|
apply := func(msg lnwire.Message) {
|
||||||
|
// TODO(elle): thread contexts through the peer system properly
|
||||||
|
// so that a parent context can be passed in here.
|
||||||
|
ctx := context.TODO()
|
||||||
|
|
||||||
// TODO(yy): `ProcessRemoteAnnouncement` returns an error chan
|
// TODO(yy): `ProcessRemoteAnnouncement` returns an error chan
|
||||||
// and we need to process it.
|
// and we need to process it.
|
||||||
p.cfg.AuthGossiper.ProcessRemoteAnnouncement(msg, p)
|
p.cfg.AuthGossiper.ProcessRemoteAnnouncement(ctx, msg, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
return newMsgStream(
|
return newMsgStream(
|
||||||
|
|||||||
Reference in new issue
Block a user