mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 14:17:56 +01:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user