pub struct HotKeyCache { /* private fields */ }Expand description
A bounded LRU KeyCache for decoded keys.
§Memory
A retained key costs roughly 2.8 KB, nearly all of it its 17-entry
multiplication table. with_capacity reserves
allocator capacity for the whole bound, but pages generally become resident
as entries are written. Size the bound from measured key reuse, or use
NullKeyCache.
Verifying another signature from a retained key reuses its decoded multiplication table instead of decompressing and tabulating it.
Implementations§
Source§impl HotKeyCache
impl HotKeyCache
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a cache holding at most capacity keys, clamped to at least one.
Reserves allocator capacity for the whole bound; see Memory.
Sourcepub fn set_capacity(&mut self, capacity: usize)
pub fn set_capacity(&mut self, capacity: usize)
Set the maximum retained key count, clamped to at least one. Lowering it
evicts excess keys and requests smaller backing allocations (the
allocator may retain freed memory); raising it reserves for the new
bound, like with_capacity.
Trait Implementations§
Source§impl Debug for HotKeyCache
impl Debug for HotKeyCache
Source§impl KeyCache for HotKeyCache
impl KeyCache for HotKeyCache
Source§fn get(&self, encoded: &[u8; 32]) -> Option<&CachedPublicKey>
fn get(&self, encoded: &[u8; 32]) -> Option<&CachedPublicKey>
None if it is absent. Implementations may
update recency state through interior mutability.