@@ -437,15 +437,19 @@ func (c *cachedNetworkMsg) Size() (uint64, error) {
437437// rejectCacheKey is the cache key that we'll use to track announcements we've
438438// recently rejected.
439439type rejectCacheKey struct {
440- pubkey [33 ]byte
441- chanID uint64
440+ gossipVersion lnwire.GossipVersion
441+ pubkey [33 ]byte
442+ chanID uint64
442443}
443444
444445// newRejectCacheKey returns a new cache key for the reject cache.
445- func newRejectCacheKey (cid uint64 , pub [33 ]byte ) rejectCacheKey {
446+ func newRejectCacheKey (v lnwire.GossipVersion , cid uint64 ,
447+ pub [33 ]byte ) rejectCacheKey {
448+
446449 k := rejectCacheKey {
447- chanID : cid ,
448- pubkey : pub ,
450+ gossipVersion : v ,
451+ chanID : cid ,
452+ pubkey : pub ,
449453 }
450454
451455 return k
@@ -1688,8 +1692,15 @@ func (d *AuthenticatedGossiper) PruneSyncState(peer route.Vertex) {
16881692func (d * AuthenticatedGossiper ) isRecentlyRejectedMsg (msg lnwire.Message ,
16891693 peerPub [33 ]byte ) bool {
16901694
1695+ // We only cache rejections for gossip messages. So if it is not
1696+ // a gossip message, we return false.
1697+ gMsg , ok := msg .(lnwire.GossipMessage )
1698+ if ! ok {
1699+ return false
1700+ }
1701+
16911702 var scid uint64
1692- switch m := msg .(type ) {
1703+ switch m := gMsg .(type ) {
16931704 case * lnwire.ChannelUpdate1 :
16941705 scid = m .ShortChannelID .ToUint64 ()
16951706
@@ -1700,8 +1711,11 @@ func (d *AuthenticatedGossiper) isRecentlyRejectedMsg(msg lnwire.Message,
17001711 return false
17011712 }
17021713
1703- _ , err := d .recentRejects .Get (newRejectCacheKey (scid , peerPub ))
1704- return err != cache .ErrElementNotFound
1714+ _ , err := d .recentRejects .Get (newRejectCacheKey (
1715+ gMsg .GossipVersion (), scid , peerPub ,
1716+ ))
1717+
1718+ return ! errors .Is (err , cache .ErrElementNotFound )
17051719}
17061720
17071721// retransmitStaleAnns examines all outgoing channels that the source node is
@@ -2571,6 +2585,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(ctx context.Context,
25712585 log .Errorf (err .Error ())
25722586
25732587 key := newRejectCacheKey (
2588+ ann .GossipVersion (),
25742589 scid .ToUint64 (),
25752590 sourceToPub (nMsg .source ),
25762591 )
@@ -2588,6 +2603,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(ctx context.Context,
25882603 log .Errorf (err .Error ())
25892604
25902605 key := newRejectCacheKey (
2606+ ann .GossipVersion (),
25912607 scid .ToUint64 (),
25922608 sourceToPub (nMsg .source ),
25932609 )
@@ -2662,6 +2678,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(ctx context.Context,
26622678 "%v" , err )
26632679
26642680 key := newRejectCacheKey (
2681+ ann .GossipVersion (),
26652682 scid .ToUint64 (),
26662683 sourceToPub (nMsg .source ),
26672684 )
@@ -2741,6 +2758,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(ctx context.Context,
27412758 errors .Is (err , ErrInvalidFundingOutput ):
27422759
27432760 key := newRejectCacheKey (
2761+ ann .GossipVersion (),
27442762 scid .ToUint64 (),
27452763 sourceToPub (nMsg .source ),
27462764 )
@@ -2750,6 +2768,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(ctx context.Context,
27502768
27512769 case errors .Is (err , ErrChannelSpent ):
27522770 key := newRejectCacheKey (
2771+ ann .GossipVersion (),
27532772 scid .ToUint64 (),
27542773 sourceToPub (nMsg .source ),
27552774 )
@@ -2776,6 +2795,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(ctx context.Context,
27762795 // edge. We won't increase the ban score for the
27772796 // remote peer.
27782797 key := newRejectCacheKey (
2798+ ann .GossipVersion (),
27792799 scid .ToUint64 (),
27802800 sourceToPub (nMsg .source ),
27812801 )
@@ -2839,6 +2859,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(ctx context.Context,
28392859 anns , rErr := d .processRejectedEdge (ctx , ann , proof )
28402860 if rErr != nil {
28412861 key := newRejectCacheKey (
2862+ ann .GossipVersion (),
28422863 scid .ToUint64 (),
28432864 sourceToPub (nMsg .source ),
28442865 )
@@ -2866,6 +2887,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(ctx context.Context,
28662887
28672888 // Otherwise, this is just a regular rejected edge.
28682889 key := newRejectCacheKey (
2890+ ann .GossipVersion (),
28692891 scid .ToUint64 (),
28702892 sourceToPub (nMsg .source ),
28712893 )
@@ -2998,6 +3020,7 @@ func (d *AuthenticatedGossiper) handleChanUpdate(ctx context.Context,
29983020 log .Errorf (err .Error ())
29993021
30003022 key := newRejectCacheKey (
3023+ upd .GossipVersion (),
30013024 upd .ShortChannelID .ToUint64 (),
30023025 sourceToPub (nMsg .source ),
30033026 )
@@ -3178,6 +3201,7 @@ func (d *AuthenticatedGossiper) handleChanUpdate(ctx context.Context,
31783201 nMsg .err <- err
31793202
31803203 key := newRejectCacheKey (
3204+ upd .GossipVersion (),
31813205 upd .ShortChannelID .ToUint64 (),
31823206 sourceToPub (nMsg .source ),
31833207 )
@@ -3307,6 +3331,7 @@ func (d *AuthenticatedGossiper) handleChanUpdate(ctx context.Context,
33073331 // Since we know the stored SCID in the graph, we'll
33083332 // cache that SCID.
33093333 key := newRejectCacheKey (
3334+ upd .GossipVersion (),
33103335 chanInfo .ChannelID ,
33113336 sourceToPub (nMsg .source ),
33123337 )
0 commit comments