Struct tor_netdoc::doc::netstatus::UnvalidatedConsensus

source ·
#[non_exhaustive]
pub struct UnvalidatedConsensus<RS> { pub consensus: Consensus<RS>, pub siggroup: SignatureGroup, pub n_authorities: Option<u16>, }
Expand description

A Microdesc consensus whose signatures have not yet been checked.

To validate this object, call set_n_authorities() on it, then call check_signature() on that result with the set of certs that you have. Make sure only to provide authority certificates representing real authorities!

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§consensus: Consensus<RS>
Available on crate feature dangerous-expose-struct-fields only.

The consensus object. We don’t want to expose this until it’s validated.

§siggroup: SignatureGroup
Available on crate feature dangerous-expose-struct-fields only.

The signatures that need to be validated before we can call this consensus valid.

§n_authorities: Option<u16>
Available on crate feature dangerous-expose-struct-fields only.

The total number of authorities that we believe in. We need this information in order to validate the signatures, since it determines how many signatures we need to find valid in siggroup.

Implementations§

source§

impl<RS> UnvalidatedConsensus<RS>

source

pub fn set_n_authorities(self, n_authorities: u16) -> Self

Tell the unvalidated consensus how many authorities we believe in.

Without knowing this number, we can’t validate the signature.

source

pub fn signing_cert_ids(&self) -> impl Iterator<Item = AuthCertKeyIds>

Return an iterator of all the certificate IDs that we might use to validate this consensus.

source

pub fn peek_lifetime(&self) -> &Lifetime

Return the lifetime of this unvalidated consensus

source

pub fn authorities_are_correct(&self, authorities: &[&RsaIdentity]) -> bool

Return true if a client who believes in exactly the provided set of authority IDs might might consider this consensus to be well-signed.

(This is the case if the consensus claims to be signed by more than half of the authorities in the list.)

source

pub fn n_relays(&self) -> usize

Available on crate feature experimental-api only.

Return the number of relays in this unvalidated consensus.

This function is unstable. It is only enabled if the crate was built with the experimental-api feature.

source

pub fn modify_relays<F>(&mut self, func: F)
where F: FnOnce(&mut Vec<RS>),

Available on crate feature experimental-api only.

Modify the list of relays in this unvalidated consensus.

A use case for this is long-lasting custom directories. To ensure Arti can still quickly build circuits when the directory gets old, a tiny churn file can be regularly obtained, listing no longer available Tor nodes, which can then be removed from the consensus.

This function is unstable. It is only enabled if the crate was built with the experimental-api feature.

Trait Implementations§

source§

impl<RS: Clone> Clone for UnvalidatedConsensus<RS>

source§

fn clone(&self) -> UnvalidatedConsensus<RS>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<RS: Debug> Debug for UnvalidatedConsensus<RS>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<RS> ExternallySigned<Consensus<RS>> for UnvalidatedConsensus<RS>

§

type Key = [AuthCert]

The type of the public key object. Read more
§

type KeyHint = Vec<AuthCertKeyIds>

A type that describes what keys are missing for this object.
§

type Error = Error

An error type that’s returned when the object is not well-signed.
source§

fn key_is_correct(&self, k: &Self::Key) -> Result<(), Self::KeyHint>

Check whether k is the right key for this object. If not, return an error describing what key would be right. Read more
source§

fn is_well_signed(&self, k: &Self::Key) -> Result<(), Self::Error>

Check the signature on this object
source§

fn dangerously_assume_wellsigned(self) -> Consensus<RS>

Unwrap this object without checking any signatures on it.
source§

fn check_signature(self, k: &Self::Key) -> Result<T, Self::Error>

Unwrap this object if it’s correctly signed by a provided key.

Auto Trait Implementations§

§

impl<RS> Freeze for UnvalidatedConsensus<RS>

§

impl<RS> RefUnwindSafe for UnvalidatedConsensus<RS>
where RS: RefUnwindSafe,

§

impl<RS> Send for UnvalidatedConsensus<RS>
where RS: Send,

§

impl<RS> Sync for UnvalidatedConsensus<RS>
where RS: Sync,

§

impl<RS> Unpin for UnvalidatedConsensus<RS>
where RS: Unpin,

§

impl<RS> UnwindSafe for UnvalidatedConsensus<RS>
where RS: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more