multi: add new config peer-msg-rate-bytes

This commit is contained in:
yyforyongyu
2025-07-22 19:18:26 +08:00
parent 778456769a
commit 5bc4666efc
6 changed files with 28 additions and 0 deletions

View File

@@ -407,6 +407,10 @@ type Config struct {
// BanThreshold is the score used to decide whether a given peer is
// banned or not.
BanThreshold uint64
// PeerMsgRateBytes is the rate limit for the number of bytes per second
// that we'll allocate to outbound gossip messages for a single peer.
PeerMsgRateBytes uint64
}
// processedNetworkMsg is a wrapper around networkMsg and a boolean. It is
@@ -609,6 +613,7 @@ func New(cfg Config, selfKeyDesc *keychain.KeyDescriptor) *AuthenticatedGossiper
AllotedMsgBytesPerSecond: cfg.MsgRateBytes,
AllotedMsgBytesBurst: cfg.MsgBurstBytes,
FilterConcurrency: cfg.FilterConcurrency,
PeerMsgBytesPerSecond: cfg.PeerMsgRateBytes,
})
gossiper.reliableSender = newReliableSender(&reliableSenderCfg{

View File

@@ -146,6 +146,11 @@ type SyncManagerCfg struct {
// FilterConcurrency is the maximum number of concurrent gossip filter
// applications that can be processed. If not set, defaults to 5.
FilterConcurrency int
// PeerMsgBytesPerSecond is the allotted bandwidth rate, expressed in
// bytes/second that a single gossip syncer can consume. Once we exceed
// this rate, message sending will block until we're below the rate.
PeerMsgBytesPerSecond uint64
}
// SyncManager is a subsystem of the gossiper that manages the gossip syncers
@@ -674,6 +679,7 @@ func (m *SyncManager) createGossipSyncer(peer lnpeer.Peer) *GossipSyncer {
maxQueryChanRangeReplies: maxQueryChanRangeReplies,
noTimestampQueryOption: m.cfg.NoTimestampQueries,
isStillZombieChannel: m.cfg.IsStillZombieChannel,
msgBytesPerSecond: m.cfg.PeerMsgBytesPerSecond,
}, m.gossipFilterSema)
// Gossip syncers are initialized by default in a PassiveSync type