discovery: rate limiting sending msgs per peer

We now add another layer of rate limiting before sending the messages
inside `GossipSyncer`.
This commit is contained in:
yyforyongyu
2025-07-22 19:17:32 +08:00
parent 6826703c77
commit 778456769a
4 changed files with 79 additions and 45 deletions

View File

@@ -26,9 +26,14 @@ func TestGossipSyncerSingleBacklogSend(t *testing.T) {
// Create a blocking sendToPeerSync function. We'll use this to simulate
// sending a large backlog.
blockingSendChan := make(chan struct{})
sendToPeerSync := func(_ context.Context,
mockSendMsg := func(_ context.Context, sync bool,
msgs ...lnwire.Message) error {
// Sync is only true when calling `sendToPeerSync`.
if !sync {
return nil
}
// Track that we're in a send goroutine.
count := activeGoroutines.Add(1)
totalGoroutinesLaunched.Add(1)
@@ -55,8 +60,8 @@ func TestGossipSyncerSingleBacklogSend(t *testing.T) {
defaultChunkSize, true, true, true,
)
// Override the sendToPeerSync to use our blocking version.
syncer.cfg.sendToPeerSync = sendToPeerSync
// Override the sendMsg to use our blocking version.
syncer.cfg.sendMsg = mockSendMsg
syncer.cfg.ignoreHistoricalFilters = false
syncer.Start()