struct ReplayShard {
current: Option<Bloom<ReplayToken>>,
previous: Option<Bloom<ReplayToken>>,
count: usize,
capacity: usize,
}Expand description
One generation pair of a shard.
Fields§
§current: Option<Bloom<ReplayToken>>The generation currently accepting insertions.
Allocated on the first insertion, not when the filter is built: at the default configuration a generation
is tens of megabytes, and a node that has not yet received a packet should not have paid for every shard of
it - nor should every HoprDecoder construction in a test or a bench.
previous: Option<Bloom<ReplayToken>>The generation that was current until the last rotation, if any.
Allocated lazily too: a shard that never fills its first generation never pays for a second bitmap.
count: usizeNumber of tokens inserted into Self::current.
capacity: usizeNumber of tokens a single generation holds before the shard rotates.
Implementations§
Source§impl ReplayShard
impl ReplayShard
Sourcefn new(capacity: usize) -> Self
fn new(capacity: usize) -> Self
Creates an empty shard that will hold capacity tokens per generation.
Sourcefn generation(capacity: usize) -> Bloom<ReplayToken>
fn generation(capacity: usize) -> Bloom<ReplayToken>
Allocates one generation sized for capacity tokens.
Sourcefn contains(&self, token: &ReplayToken) -> bool
fn contains(&self, token: &ReplayToken) -> bool
Whether either generation holds token.
Sourcefn check_and_set(&mut self, token: &ReplayToken) -> bool
fn check_and_set(&mut self, token: &ReplayToken) -> bool
Inserts token unless it is already known. Returns true if it was already known.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ReplayShard
impl RefUnwindSafe for ReplayShard
impl Send for ReplayShard
impl Sync for ReplayShard
impl Unpin for ReplayShard
impl UnsafeUnpin for ReplayShard
impl UnwindSafe for ReplayShard
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
§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