pub struct VerifiedCache { /* private fields */ }Expand description
LRU cache for verified XorName values.
This cache stores XorName values that have been verified to exist on the
autonomi network, avoiding repeated network queries for the same data.
Each entry carries a flag recording whether the verification that inserted
it ran the full client-PUT check set (true) or only the
receipt-authenticity subset used for replication (false). A
replication-verified entry must not satisfy a later client-PUT fast-path —
the context-gated checks (own-quote freshness, local recipient, merkle
candidate closeness) were never run for it — while either kind of entry
satisfies a later replication check.
Implementations§
Source§impl VerifiedCache
impl VerifiedCache
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a new cache with the specified capacity.
If capacity is 0, defaults to 1.
Sourcepub fn contains(&self, xorname: &XorName) -> bool
pub fn contains(&self, xorname: &XorName) -> bool
Check if a XorName is in the cache (verified under either check set).
Returns true if the XorName is cached (verified to exist on autonomi).
Sufficient for replication-context lookups; client-PUT lookups must use
Self::contains_client_put_verified.
Sourcepub fn contains_client_put_verified(&self, xorname: &XorName) -> bool
pub fn contains_client_put_verified(&self, xorname: &XorName) -> bool
Check if a XorName is cached AND its verification ran the full
client-PUT check set.
A replication-verified entry returns false here: it never passed the
client-PUT-only checks, so it must not let a later client PUT skip them.
Sourcepub fn insert(&self, xorname: XorName)
pub fn insert(&self, xorname: XorName)
Add a XorName verified under the full client-PUT check set.
This should be called after verifying that data exists on the autonomi network. Also upgrades an existing replication-verified entry.
Sourcepub fn insert_replication_verified(&self, xorname: XorName)
pub fn insert_replication_verified(&self, xorname: XorName)
Add a XorName verified under the replication (receipt-authenticity)
subset only.
Never downgrades an existing client-PUT-verified entry — the stronger verification already happened, and replication re-offers of the same key are routine.
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get current cache statistics.
Trait Implementations§
Source§impl Clone for VerifiedCache
impl Clone for VerifiedCache
Source§fn clone(&self) -> VerifiedCache
fn clone(&self) -> VerifiedCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for VerifiedCache
impl !UnwindSafe for VerifiedCache
impl Freeze for VerifiedCache
impl Send for VerifiedCache
impl Sync for VerifiedCache
impl Unpin for VerifiedCache
impl UnsafeUnpin for VerifiedCache
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more