diff --git a/discovery/gossiper.go b/discovery/gossiper.go index 87dcde7c..845bce46 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -228,6 +228,11 @@ type Config struct { // This prevents ranges with old start times from causing us to dump the // graph on connect. IgnoreHistoricalFilters bool + + // GossipUpdateThrottle if true, then the gossiper will throttle + // gossip updates to once per RebroadcastInterval for any keep-alive + // updates, and once per block for other types of updates. + GossipUpdateThrottle bool } // AuthenticatedGossiper is a subsystem which is responsible for receiving @@ -1965,8 +1970,9 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement( // If we have a previous version of the edge being updated, // we'll want to rate limit its updates to prevent spam - // throughout the network. - if nMsg.isRemote && edgeToUpdate != nil { + // throughout the network if we're currently throttling such + // updates. + if d.cfg.GossipUpdateThrottle && nMsg.isRemote && edgeToUpdate != nil { // If it's a keep-alive update, we'll only propagate one // if it's been a day since the previous. This follows // our own heuristic of sending keep-alive updates after diff --git a/discovery/gossiper_test.go b/discovery/gossiper_test.go index fc227148..728cf1ec 100644 --- a/discovery/gossiper_test.go +++ b/discovery/gossiper_test.go @@ -3957,6 +3957,7 @@ func TestRateLimitChannelUpdates(t *testing.T) { } defer cleanup() ctx.gossiper.cfg.RebroadcastInterval = time.Hour + ctx.gossiper.cfg.GossipUpdateThrottle = true // The graph should start empty. require.Empty(t, ctx.router.infos) diff --git a/server.go b/server.go index 13e1462b..72c9b612 100644 --- a/server.go +++ b/server.go @@ -804,6 +804,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr, MinimumBatchSize: 10, SubBatchDelay: time.Second * 5, IgnoreHistoricalFilters: cfg.IgnoreHistoricalGossipFilters, + GossipUpdateThrottle: !cfg.ProtocolOptions.NoGossipThrottle(), }, s.identityECDH.PubKey(), )