pub struct OptimizedProofCache { /* private fields */ }Expand description
Optimized proof cache with hash table for O(1) operations.
Uses open addressing with linear probing for collision resolution. Cache-line aligned entries minimize memory access overhead.
Implementations§
Source§impl OptimizedProofCache
impl OptimizedProofCache
Sourcepub fn insert(
&mut self,
mutation_hash: [u8; 32],
nonce: u64,
proof_id: u32,
current_time_ns: u64,
) -> Result<(), CacheError>
pub fn insert( &mut self, mutation_hash: [u8; 32], nonce: u64, proof_id: u32, current_time_ns: u64, ) -> Result<(), CacheError>
Inserts a new proof into the cache (O(1) amortized).
Uses open addressing with linear probing.
Sourcepub fn verify_and_consume(
&mut self,
mutation_hash: &[u8; 32],
nonce: u64,
current_time_ns: u64,
) -> Result<u32, CacheError>
pub fn verify_and_consume( &mut self, mutation_hash: &[u8; 32], nonce: u64, current_time_ns: u64, ) -> Result<u32, CacheError>
Verifies and consumes a proof (O(1) amortized, <100ns target).
This is the hot path - optimized for:
- Single hash computation
- Minimal cache line accesses
- Single atomic write for consumption
Sourcepub fn exists(
&self,
mutation_hash: &[u8; 32],
nonce: u64,
current_time_ns: u64,
) -> bool
pub fn exists( &self, mutation_hash: &[u8; 32], nonce: u64, current_time_ns: u64, ) -> bool
Checks if a proof exists without consuming it.
Sourcepub fn evict_expired(&mut self, current_time_ns: u64)
pub fn evict_expired(&mut self, current_time_ns: u64)
Evicts all expired entries.
Sourcepub const fn generation(&self) -> u64
pub const fn generation(&self) -> u64
Returns the current generation counter.
Trait Implementations§
Source§impl Debug for OptimizedProofCache
impl Debug for OptimizedProofCache
Auto Trait Implementations§
impl Freeze for OptimizedProofCache
impl RefUnwindSafe for OptimizedProofCache
impl Send for OptimizedProofCache
impl Sync for OptimizedProofCache
impl Unpin for OptimizedProofCache
impl UnsafeUnpin for OptimizedProofCache
impl UnwindSafe for OptimizedProofCache
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