From d0e8aeece1ed31c1faac388a63f7becc0d95bf67 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Mon, 20 Aug 2018 14:28:09 +0200 Subject: [PATCH] discovery/gossiper: return on errChan in case of ChanAnn/Upd on wrong chain Previously we wouldn't return anything in the case where the announcement were meant for a chain we didn't recognize. After this change we should return an error on the error channel in all flows within the gossiper. --- discovery/gossiper.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/discovery/gossiper.go b/discovery/gossiper.go index c75f3f61..ce602cae 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -1653,12 +1653,16 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(nMsg *networkMsg) []n // We'll ignore any channel announcements that target any chain // other than the set of chains we know of. if !bytes.Equal(msg.ChainHash[:], d.cfg.ChainHash[:]) { - log.Errorf("Ignoring ChannelAnnouncement from "+ + err := fmt.Errorf("Ignoring ChannelAnnouncement from "+ "chain=%v, gossiper on chain=%v", msg.ChainHash, d.cfg.ChainHash) + log.Errorf(err.Error()) + d.rejectMtx.Lock() d.recentRejects[msg.ShortChannelID.ToUint64()] = struct{}{} d.rejectMtx.Unlock() + + nMsg.err <- err return nil } @@ -1863,12 +1867,16 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(nMsg *networkMsg) []n // We'll ignore any channel announcements that target any chain // other than the set of chains we know of. if !bytes.Equal(msg.ChainHash[:], d.cfg.ChainHash[:]) { - log.Errorf("Ignoring ChannelUpdate from "+ + err := fmt.Errorf("Ignoring ChannelUpdate from "+ "chain=%v, gossiper on chain=%v", msg.ChainHash, d.cfg.ChainHash) + log.Errorf(err.Error()) + d.rejectMtx.Lock() d.recentRejects[msg.ShortChannelID.ToUint64()] = struct{}{} d.rejectMtx.Unlock() + + nMsg.err <- err return nil }