pub struct AnnounceSignatureCache { /* private fields */ }Expand description
Bounded TTL cache for announce signature verification results.
Stores hashes of recently verified (destination_hash, signature) pairs so
that duplicate announces from multiple peers skip redundant Ed25519
verification. Entries expire after ttl_secs and are culled periodically.
When max_entries is 0 the cache is disabled and all methods are no-ops.
Implementations§
Source§impl AnnounceSignatureCache
impl AnnounceSignatureCache
pub fn new(max_entries: usize, ttl_secs: f64) -> Self
Sourcepub fn contains(&self, key: &[u8; 32]) -> bool
pub fn contains(&self, key: &[u8; 32]) -> bool
Check if a cache key is present (i.e., already verified).
Sourcepub fn insert(&mut self, key: [u8; 32], now: f64)
pub fn insert(&mut self, key: [u8; 32], now: f64)
Insert a verified cache key with the current timestamp.
Sourcepub fn cull(&mut self, now: f64) -> usize
pub fn cull(&mut self, now: f64) -> usize
Remove entries older than TTL. Returns the number of entries removed.
pub fn len(&self) -> usize
Auto Trait Implementations§
impl Freeze for AnnounceSignatureCache
impl RefUnwindSafe for AnnounceSignatureCache
impl Send for AnnounceSignatureCache
impl Sync for AnnounceSignatureCache
impl Unpin for AnnounceSignatureCache
impl UnsafeUnpin for AnnounceSignatureCache
impl UnwindSafe for AnnounceSignatureCache
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