Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
feat: set filter number boundary
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi committed Dec 24, 2020
1 parent b9e3586 commit c129bff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/consensus/dkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,7 @@ mod tests {
self.outcome = Some(outcome.public_key_set.public_key());
vec![]
}
DkgCommand::ScheduleTimeout { .. } => {
vec![]
}
DkgCommand::ScheduleTimeout { .. } => vec![],
DkgCommand::SendFailureObservation { .. }
| DkgCommand::HandleFailureAgreement { .. } => {
panic!("unexpected command: {:?}", command)
Expand Down
11 changes: 9 additions & 2 deletions src/message_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use xor_name::XorName;

const INCOMING_EXPIRY_DURATION: Duration = Duration::from_secs(20 * 60);
const OUTGOING_EXPIRY_DURATION: Duration = Duration::from_secs(10 * 60);
const MAX_ENTRIES: usize = 5_000;

/// An enum representing a result of message filtering
#[derive(Eq, PartialEq)]
Expand Down Expand Up @@ -44,8 +45,14 @@ pub(crate) struct MessageFilter {
impl MessageFilter {
pub fn new() -> Self {
Self {
incoming: LruCache::with_expiry_duration(INCOMING_EXPIRY_DURATION),
outgoing: LruCache::with_expiry_duration(OUTGOING_EXPIRY_DURATION),
incoming: LruCache::with_expiry_duration_and_capacity(
INCOMING_EXPIRY_DURATION,
MAX_ENTRIES,
),
outgoing: LruCache::with_expiry_duration_and_capacity(
OUTGOING_EXPIRY_DURATION,
MAX_ENTRIES,
),
}
}

Expand Down

0 comments on commit c129bff

Please sign in to comment.