pub struct HsDirParams {
pub(crate) time_period: TimePeriod,
pub(crate) shared_rand: SharedRandVal,
pub(crate) srv_lifespan: Range<SystemTime>,
}
hs-common
only.Expand description
Parameters for generating and using an HsDir ring.
These parameters are derived from the shared random values and time parameters in the consensus, and are used to determine the position of each HsDir within the ring.
Fields§
§time_period: TimePeriod
The time period for this ring. It’s used to ensure that blinded onion keys rotate in a predictable way over time.
The SharedRandVal for this ring. It’s used to ensure that the position of each HsDir within the ring rotates unpredictably over time.
srv_lifespan: Range<SystemTime>
The range of times over which the srv is most current.
Implementations§
Source§impl HsDirParams
impl HsDirParams
Sourcepub fn time_period(&self) -> TimePeriod
pub fn time_period(&self) -> TimePeriod
Return the time period for which these parameters are valid.
The hs_blind_id
for an onion service changes every time period: when
uploading, callers should use this time period to determine which
hs_blind_id
’s descriptor should be sent to which directory.
Sourcepub fn start_of_shard_rand_period(&self) -> SystemTime
pub fn start_of_shard_rand_period(&self) -> SystemTime
Return the starting time for the shared-random-value protocol that produced the SRV for this time period.
Sourcepub fn offset_within_srv_period(
&self,
when: SystemTime,
) -> Option<SrvPeriodOffset>
Available on crate feature hs-service
only.
pub fn offset_within_srv_period( &self, when: SystemTime, ) -> Option<SrvPeriodOffset>
hs-service
only.Return an opaque offset for when
from the start of the shared-random-value protocol
period corresponding to the SRV for this time period.
When uploading, callers should this offset to determine the revision counter for their descriptors.
Returns None
if when is after the start of the SRV period.
Sourcepub(crate) fn compute(
consensus: &MdConsensus,
params: &NetParameters,
) -> Result<HsDirs<HsDirParams>>
pub(crate) fn compute( consensus: &MdConsensus, params: &NetParameters, ) -> Result<HsDirs<HsDirParams>>
Compute the HsDirParams
for the current time period, according to a given
consensus.
rend-spec-v3 section 2.2.1 et seq
Return the ring parameters for the current period (which clients use when fetching onion service descriptors), along with a Vec of ring parameters for any secondary periods that onion services should additionally use when publishing their descriptors.
Note that “current” here is always relative to a given consensus, not the current wall-clock time.
(This function’s return type is a bit cumbersome; these parameters are bundled together because it is efficient to compute them all at once.)
Note that this function will only return an error if something is extremely wrong with the provided consensus: for other error cases, it returns a “disaster fallback”.
Trait Implementations§
Source§impl Clone for HsDirParams
impl Clone for HsDirParams
Source§fn clone(&self) -> HsDirParams
fn clone(&self) -> HsDirParams
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for HsDirParams
impl Debug for HsDirParams
Source§impl PartialEq for HsDirParams
impl PartialEq for HsDirParams
impl Eq for HsDirParams
impl StructuralPartialEq for HsDirParams
Auto Trait Implementations§
impl Freeze for HsDirParams
impl RefUnwindSafe for HsDirParams
impl Send for HsDirParams
impl Sync for HsDirParams
impl Unpin for HsDirParams
impl UnwindSafe for HsDirParams
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§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