Skip to content

Commit

Permalink
consensus: remove remove_msgs_greater_than
Browse files Browse the repository at this point in the history
  • Loading branch information
fed-franz committed Aug 22, 2024
1 parent 9c555a9 commit 8d0af45
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions consensus/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ impl<T: Debug + Clone> MsgRegistry<T> {
self.0.remove(&round);
}

/// Removes all messages that belong to a round greater than the specified.
pub fn remove_msgs_greater_than(&mut self, round: u64) {
self.0.split_off(&round);
}

/// Removes all messages that do not belong to the range (closed interval)
/// of keys
pub fn remove_msgs_out_of_range(&mut self, start_round: u64, offset: u64) {
Expand Down Expand Up @@ -121,30 +116,6 @@ mod tests {
assert!(reg.drain_msg_by_round_step(round, 2).is_none());
}

#[test]
fn test_remove() {
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
struct Item(i32);

let round = 100;

let mut reg = MsgRegistry::<Item>::default();
reg.put_msg(round + 1, 1, Item(1));
reg.put_msg(round + 2, 1, Item(1));
reg.put_msg(round + 3, 1, Item(1));
reg.put_msg(round, 1, Item(1));

reg.remove_msgs_greater_than(round + 2);

assert!(reg.drain_msg_by_round_step(round, 1).is_some());
assert!(reg.drain_msg_by_round_step(round + 1, 1).is_some());

assert!(reg.drain_msg_by_round_step(round + 2, 1).is_none());
assert!(reg.drain_msg_by_round_step(round + 3, 1).is_none());

assert_eq!(reg.msg_count(), 0);
}

#[test]
fn test_remove_msgs_out_of_range() {
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
Expand Down

0 comments on commit 8d0af45

Please sign in to comment.