pub struct ProtocolHandle { /* private fields */ }
Expand description
Shared handle to ProtocolController
. Distributed around the code outside of the
protocol implementation.
Implementations§
Source§impl ProtocolHandle
impl ProtocolHandle
Sourcepub fn add_reserved_peer(&self, peer_id: PeerId)
pub fn add_reserved_peer(&self, peer_id: PeerId)
Adds a new reserved peer. ProtocolController
will make an effort
to always remain connected to this peer.
Has no effect if the node was already a reserved peer.
Note: Keep in mind that the networking has to know an address for this node, otherwise it will not be able to connect to it.
Sourcepub fn remove_reserved_peer(&self, peer_id: PeerId)
pub fn remove_reserved_peer(&self, peer_id: PeerId)
Demotes reserved peer to non-reserved. Does not disconnect the peer.
Has no effect if the node was not a reserved peer.
Sourcepub fn set_reserved_peers(&self, peer_ids: HashSet<PeerId>)
pub fn set_reserved_peers(&self, peer_ids: HashSet<PeerId>)
Set reserved peers to the new set.
Sourcepub fn set_reserved_only(&self, reserved: bool)
pub fn set_reserved_only(&self, reserved: bool)
Sets whether or not ProtocolController
only has connections with nodes marked
as reserved for the given set.
Sourcepub fn disconnect_peer(&self, peer_id: PeerId)
pub fn disconnect_peer(&self, peer_id: PeerId)
Disconnect peer. You should remove the PeerId
from the PeerStore
first
to not connect to the peer again during the next slot allocation.
Sourcepub fn reserved_peers(&self, pending_response: Sender<Vec<PeerId>>)
pub fn reserved_peers(&self, pending_response: Sender<Vec<PeerId>>)
Get the list of reserved peers.
Sourcepub fn incoming_connection(
&self,
peer_id: PeerId,
incoming_index: IncomingIndex,
)
pub fn incoming_connection( &self, peer_id: PeerId, incoming_index: IncomingIndex, )
Notify about incoming connection. ProtocolController
will either accept or reject it.
Trait Implementations§
Source§impl Clone for ProtocolHandle
impl Clone for ProtocolHandle
Source§fn clone(&self) -> ProtocolHandle
fn clone(&self) -> ProtocolHandle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ProtocolHandle
impl Debug for ProtocolHandle
Source§impl ProtocolHandle for ProtocolHandle
impl ProtocolHandle for ProtocolHandle
Source§fn disconnect_peer(&self, peer_id: PeerId)
fn disconnect_peer(&self, peer_id: PeerId)
Auto Trait Implementations§
impl Freeze for ProtocolHandle
impl RefUnwindSafe for ProtocolHandle
impl Send for ProtocolHandle
impl Sync for ProtocolHandle
impl Unpin for ProtocolHandle
impl UnwindSafe for ProtocolHandle
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§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> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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 moreSource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read moreSource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.