From bb54fd5b450ea1b126f7c31845f12893bf061058 Mon Sep 17 00:00:00 2001 From: Aria Date: Thu, 19 Oct 2023 23:40:51 +0100 Subject: don't check max batch size --- broadcast/src/batch.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'broadcast/src/batch.rs') diff --git a/broadcast/src/batch.rs b/broadcast/src/batch.rs index 46b9b57..d69771d 100644 --- a/broadcast/src/batch.rs +++ b/broadcast/src/batch.rs @@ -18,16 +18,14 @@ const RETRY_TIMEOUT_SECS: u64 = 1; #[derive(Debug, Clone)] pub struct MessageBatch { max_message_delay: Duration, - max_message_count: usize, first_added: Instant, messages: HashSet, } impl MessageBatch { - pub fn new(max_message_delay: Duration, max_message_count: usize) -> Self { + pub fn new(max_message_delay: Duration) -> Self { Self { max_message_delay, - max_message_count, first_added: Instant::now(), messages: HashSet::new(), } @@ -45,9 +43,7 @@ impl MessageBatch { } pub fn should_broadcast(&self) -> bool { - !self.messages.is_empty() - && (self.first_added.elapsed() >= self.max_message_delay - || self.messages.len() >= self.max_message_count) + !self.messages.is_empty() && self.first_added.elapsed() >= self.max_message_delay } pub fn sleep_time(&self) -> Duration { -- cgit v1.2.3