pub struct MemorySurbStore {
pseudonym_openers: Cache<HoprPseudonym, Cache<HoprSurbId, ReplyOpener>>,
surbs_per_pseudonym: Cache<HoprPseudonym, SurbRingBuffer<HoprSurb>>,
invalidated_relayers: Arc<RwLock<HashSet<HoprKeyIdent>>>,
reporters: Arc<EvictionReporters>,
cfg: Arc<SurbStoreConfig>,
}Expand description
Basic SurbStore implementation based on an in-memory cache.
This SURB store offers no persistence, and all SURBs and Reply Openers are lost once dropped.
The instance can be cheaply cloned.
Fields§
§pseudonym_openers: Cache<HoprPseudonym, Cache<HoprSurbId, ReplyOpener>>§surbs_per_pseudonym: Cache<HoprPseudonym, SurbRingBuffer<HoprSurb>>§invalidated_relayers: Arc<RwLock<HashSet<HoprKeyIdent>>>Relayers this node can no longer pay. Holds at most a handful of entries (our own closing
channels), so a plain set behind an RwLock beats a concurrent map on this read-heavy path.
reporters: Arc<EvictionReporters>§cfg: Arc<SurbStoreConfig>Implementations§
Source§impl MemorySurbStore
impl MemorySurbStore
Sourcepub fn new(cfg: SurbStoreConfig) -> Self
pub fn new(cfg: SurbStoreConfig) -> Self
Creates a new instance with the given configuration.
Sourcepub fn is_relayer_invalidated(&self, relayer: &HoprKeyIdent) -> bool
pub fn is_relayer_invalidated(&self, relayer: &HoprKeyIdent) -> bool
Whether relayer is currently unusable as a return path’s first hop.
Sourcefn is_surb_usable(&self, surb: &HoprSurb) -> bool
fn is_surb_usable(&self, surb: &HoprSurb) -> bool
Whether a stored SURB can still be used to reply: its first relayer must still be payable.
A direct return path is exempt — its “first relayer” is the final recipient, which needs no channel (RFC-0003 §3.2, RFC-0006 §6.1). Without that exemption, closing an unrelated channel to a session’s originator would discard perfectly good SURBs.
Trait Implementations§
Source§impl Clone for MemorySurbStore
impl Clone for MemorySurbStore
Source§fn clone(&self) -> MemorySurbStore
fn clone(&self) -> MemorySurbStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for MemorySurbStore
impl Default for MemorySurbStore
Source§impl SurbStore for MemorySurbStore
impl SurbStore for MemorySurbStore
Source§fn insert_surbs(
&self,
pseudonym: HoprPseudonym,
surbs: Vec<(HoprSurbId, HoprSurb)>,
) -> SurbInsertOutcome
fn insert_surbs( &self, pseudonym: HoprPseudonym, surbs: Vec<(HoprSurbId, HoprSurb)>, ) -> SurbInsertOutcome
Source§fn insert_reply_opener(&self, sender_id: HoprSenderId, opener: ReplyOpener)
fn insert_reply_opener(&self, sender_id: HoprSenderId, opener: ReplyOpener)
Source§fn invalidate_relayer(&self, relayer: &HoprKeyIdent)
fn invalidate_relayer(&self, relayer: &HoprKeyIdent)
relayer as unusable, so stored SURBs whose return path
starts there are no longer handed out. Read moreSource§fn revalidate_relayer(&self, relayer: &HoprKeyIdent)
fn revalidate_relayer(&self, relayer: &HoprKeyIdent)
Source§fn find_reply_opener(&self, sender_id: &HoprSenderId) -> Option<ReplyOpener>
fn find_reply_opener(&self, sender_id: &HoprSenderId) -> Option<ReplyOpener>
Auto Trait Implementations§
impl !RefUnwindSafe for MemorySurbStore
impl !UnwindSafe for MemorySurbStore
impl Freeze for MemorySurbStore
impl Send for MemorySurbStore
impl Sync for MemorySurbStore
impl Unpin for MemorySurbStore
impl UnsafeUnpin for MemorySurbStore
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,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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