summaryrefslogtreecommitdiff
path: root/broadcast/src/batch.rs
diff options
context:
space:
mode:
authorAria <me@aria.rip>2023-10-19 23:40:51 +0100
committerAria <me@aria.rip>2023-10-19 23:40:51 +0100
commitbb54fd5b450ea1b126f7c31845f12893bf061058 (patch)
tree197cb19750e1ec15dd977dd2d245baec7273c313 /broadcast/src/batch.rs
parent1ec89fafc0afc27758924ae9f0102c9871918514 (diff)
don't check max batch size
Diffstat (limited to 'broadcast/src/batch.rs')
-rw-r--r--broadcast/src/batch.rs8
1 files changed, 2 insertions, 6 deletions
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<BroadcastTarget>,
}
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 {