Struct sc_network::protocol_controller::ProtocolHandle
source · 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 moreAuto 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<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> 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, 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.