Skip to main content

OptimizedProofCache

Struct OptimizedProofCache 

Source
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

Source

pub const fn new() -> Self

Creates a new empty optimized proof cache.

Source

pub const fn len(&self) -> usize

Returns the number of active entries.

Source

pub const fn is_empty(&self) -> bool

Returns true if cache is empty.

Source

pub const fn is_full(&self) -> bool

Returns true if cache is full.

Source

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.

Source

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
Source

pub fn exists( &self, mutation_hash: &[u8; 32], nonce: u64, current_time_ns: u64, ) -> bool

Checks if a proof exists without consuming it.

Source

pub fn evict_expired(&mut self, current_time_ns: u64)

Evicts all expired entries.

Source

pub fn clear(&mut self)

Clears all entries.

Source

pub const fn generation(&self) -> u64

Returns the current generation counter.

Trait Implementations§

Source§

impl Debug for OptimizedProofCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OptimizedProofCache

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.