1
0
mirror of synced 2025-01-09 15:26:11 +00:00

Limit in-flight requests in chat app (#562)

This commit is contained in:
Giacomo Pasini 2024-01-19 14:17:10 +01:00 committed by GitHub
parent d527050633
commit aeaf13fc88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -48,6 +48,8 @@ use ratatui::{
use tui_input::{backend::crossterm::EventHandler, Input}; use tui_input::{backend::crossterm::EventHandler, Input};
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(120); const DEFAULT_TIMEOUT: Duration = Duration::from_secs(120);
// Limit the number of maximum in-flight requests
const MAX_BUFFERED_REQUESTS: usize = 20;
#[derive(Clone, Debug, Args)] #[derive(Clone, Debug, Args)]
/// The almost-instant messaging protocol. /// The almost-instant messaging protocol.
@ -299,7 +301,7 @@ async fn fetch_new_messages(
process_block_blobs(node, block, da_settings) process_block_blobs(node, block, da_settings)
}) })
.buffer_unordered(new_blocks.len()) .buffered(MAX_BUFFERED_REQUESTS)
.collect::<Vec<_>>() .collect::<Vec<_>>()
.await; .await;