pub(crate) struct HsDirs<D> {
pub(crate) current: D,
pub(crate) secondary: Vec<D>,
}
hs-common
only.Expand description
Collection of hidden service directories (or parameters for them)
In NetDir
this is used to store the actual hash rings.
(But, in a NetDir in a PartialNetDir
, it contains HsDirRing
s
where only the params
are populated, and the ring
is empty.)
This same generic type is used as the return type from
HsDirParams::compute
,
where it contains the parameters for the primary and secondary rings.
Fields§
§current: D
The current ring
It corresponds to the time period containing the valid-after
time in
the consensus. Its SRV is whatever SRV was most current at the time when
that time period began.
This is the hash ring that we should use whenever we are fetching an onion service descriptor.
secondary: Vec<D>
hs-service
only.Secondary rings (based on the parameters for the previous and next time periods)
Onion services upload to positions on these ring as well, based on how far into the current time period this directory is, so that not-synchronized clients can still find their descriptor.
Note that with the current (2023) network parameters, with
hsdir_interval = SRV lifetime = 24 hours
at most one of these
secondary rings will be active at a time. We have two here in order
to conform with a more flexible regime in proposal 342.
Implementations§
Source§impl<D> HsDirs<D>
impl<D> HsDirs<D>
Sourcepub(crate) fn map<D2>(self, f: impl FnMut(D) -> D2) -> HsDirs<D2>
pub(crate) fn map<D2>(self, f: impl FnMut(D) -> D2) -> HsDirs<D2>
Convert an HsDirs<D>
to HsDirs<D2>
by mapping each contained D
Sourcepub(crate) fn iter_filter_secondary(
&self,
secondary: bool,
) -> impl Iterator<Item = &D>
pub(crate) fn iter_filter_secondary( &self, secondary: bool, ) -> impl Iterator<Item = &D>
Iterate over some of the contained hsdirs, according to secondary
The current ring is always included.
Secondary rings are included iff secondary
and the hs-service
feature is enabled.
Sourcepub(crate) fn iter_for_op(&self, op: HsDirOp) -> impl Iterator<Item = &D>
pub(crate) fn iter_for_op(&self, op: HsDirOp) -> impl Iterator<Item = &D>
Iterate over the hsdirs relevant for op
Trait Implementations§
Auto Trait Implementations§
impl<D> Freeze for HsDirs<D>where
D: Freeze,
impl<D> RefUnwindSafe for HsDirs<D>where
D: RefUnwindSafe,
impl<D> Send for HsDirs<D>where
D: Send,
impl<D> Sync for HsDirs<D>where
D: Sync,
impl<D> Unpin for HsDirs<D>where
D: Unpin,
impl<D> UnwindSafe for HsDirs<D>where
D: UnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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