pub struct Handler<A: AddressingInformation> {
peers_by_node: HashMap<NodeIndex, A::PeerId>,
authentications: HashMap<A::PeerId, Authentication<A>>,
session_info: SessionInfo<A>,
own_peer_id: A::PeerId,
authority_index_and_pen: Option<(NodeIndex, AuthorityPen)>,
authority_verifier: AuthorityVerifier,
}
Expand description
A struct for handling authentications for a given session and maintaining mappings between PeerIds and NodeIndexes within that session.
Fields§
§peers_by_node: HashMap<NodeIndex, A::PeerId>
§authentications: HashMap<A::PeerId, Authentication<A>>
§session_info: SessionInfo<A>
§own_peer_id: A::PeerId
Implementations§
source§impl<A: AddressingInformation> Handler<A>
impl<A: AddressingInformation> Handler<A>
sourcepub fn new(
authority_index_and_pen: Option<(NodeIndex, AuthorityPen)>,
authority_verifier: AuthorityVerifier,
session_id: SessionId,
address: A
) -> Handler<A>
pub fn new( authority_index_and_pen: Option<(NodeIndex, AuthorityPen)>, authority_verifier: AuthorityVerifier, session_id: SessionId, address: A ) -> Handler<A>
Creates a new session handler. It will be a validator session handler if the authority index and pen are provided.
fn index(&self) -> Option<NodeIndex>
pub fn is_validator(&self) -> bool
pub fn node_count(&self) -> NodeCount
pub fn session_id(&self) -> SessionId
sourcepub fn authentication(&self) -> Option<Authentication<A>>
pub fn authentication(&self) -> Option<Authentication<A>>
Returns the authentication for the node and session this handler is responsible for.
sourcepub fn missing_nodes(&self) -> Vec<NodeIndex>
pub fn missing_nodes(&self) -> Vec<NodeIndex>
Returns a vector of indices of nodes for which the handler has no authentication.
sourcepub fn handle_authentication(
&mut self,
authentication: Authentication<A>
) -> Option<A>
pub fn handle_authentication( &mut self, authentication: Authentication<A> ) -> Option<A>
Verifies the authentication, uses it to update mappings, and returns the address we should stay connected to if any.
sourcepub fn peer_id(&self, node_id: &NodeIndex) -> Option<A::PeerId>
pub fn peer_id(&self, node_id: &NodeIndex) -> Option<A::PeerId>
Returns the PeerId of the node with the given NodeIndex, if known.
sourcepub fn update(
&mut self,
authority_index_and_pen: Option<(NodeIndex, AuthorityPen)>,
authority_verifier: AuthorityVerifier,
address: A
) -> Result<Vec<A>, HandlerError>
pub fn update( &mut self, authority_index_and_pen: Option<(NodeIndex, AuthorityPen)>, authority_verifier: AuthorityVerifier, address: A ) -> Result<Vec<A>, HandlerError>
Updates the handler with the given keychain and set of own addresses. Returns an error if the set of addresses is not valid. All authentications will be rechecked, invalid ones purged. Own authentication will be regenerated. If successful returns a set of addresses that we should be connected to.
Auto Trait Implementations§
impl<A> !RefUnwindSafe for Handler<A>
impl<A> Send for Handler<A>
impl<A> Sync for Handler<A>
impl<A> Unpin for Handler<A>
impl<A> !UnwindSafe for Handler<A>
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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<T> CheckedConversion for T
impl<T> CheckedConversion for T
§fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
§fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T>where
Self: TryInto<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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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§impl<T> IsType<T> for T
impl<T> IsType<T> for T
§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read more§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.