pub struct PacketHashlist { /* private fields */ }Expand description
Double-buffered packet hash deduplication.
Uses two BTreeSets: current and previous. When the current set
grows past max_size / 2, it rotates: current becomes previous,
and a new empty set becomes current. This means the oldest hashes
are forgotten after two rotations.
Implementations§
Source§impl PacketHashlist
impl PacketHashlist
pub fn new(max_size: usize) -> Self
Sourcepub fn is_duplicate(&self, hash: &[u8; 32]) -> bool
pub fn is_duplicate(&self, hash: &[u8; 32]) -> bool
Check if a hash is a duplicate (exists in current or previous set).
Sourcepub fn maybe_rotate(&mut self) -> bool
pub fn maybe_rotate(&mut self) -> bool
Rotate if current set exceeds max_size / 2. Returns true if rotation occurred.
Sourcepub fn current_len(&self) -> usize
pub fn current_len(&self) -> usize
Number of hashes in the current set only.
Auto Trait Implementations§
impl Freeze for PacketHashlist
impl RefUnwindSafe for PacketHashlist
impl Send for PacketHashlist
impl Sync for PacketHashlist
impl Unpin for PacketHashlist
impl UnwindSafe for PacketHashlist
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more