summaryrefslogtreecommitdiff
path: root/broadcast/src/batch.rs
diff options
context:
space:
mode:
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 {