pub struct Router { /* private fields */ }Expand description
A router object for managing the communication to a network peer. It is named a router because it’s responsible for internally routing messages to P2P flows based on registration and message types
Implementations§
Source§impl Router
impl Router
pub fn set_identity(&self, identity: PeerId)
Sourcepub fn net_address(&self) -> SocketAddr
pub fn net_address(&self) -> SocketAddr
The socket address of this peer
pub fn key(&self) -> PeerKey
Sourcepub fn is_outbound(&self) -> bool
pub fn is_outbound(&self) -> bool
Indicates whether this connection is an outbound connection
pub fn connection_started(&self) -> Instant
pub fn time_connected(&self) -> u64
pub fn properties(&self) -> Arc<PeerProperties>
pub fn set_properties(&self, properties: Arc<PeerProperties>)
Sourcepub fn set_last_ping_duration(&self, last_ping_duration: u64)
pub fn set_last_ping_duration(&self, last_ping_duration: u64)
Sets the duration of the last ping
pub fn last_ping_duration(&self) -> u64
pub fn incoming_flow_baseline_channel_size() -> usize
Sourcepub fn subscribe(
&self,
msg_types: Vec<KaspadMessagePayloadType>,
) -> IncomingRoute
pub fn subscribe( &self, msg_types: Vec<KaspadMessagePayloadType>, ) -> IncomingRoute
Subscribe to specific message types.
This should be used by ConnectionInitializer instances to register application-specific flows
Sourcepub fn subscribe_with_capacity(
&self,
msg_types: Vec<KaspadMessagePayloadType>,
capacity: usize,
) -> IncomingRoute
pub fn subscribe_with_capacity( &self, msg_types: Vec<KaspadMessagePayloadType>, capacity: usize, ) -> IncomingRoute
Subscribe to specific message types with a specific channel capacity.
This should be used by ConnectionInitializer instances to register application-specific flows.
Sourcepub fn route_to_flow(&self, msg: KaspadMessage) -> Result<(), ProtocolError>
pub fn route_to_flow(&self, msg: KaspadMessage) -> Result<(), ProtocolError>
Routes a message coming from the network to the corresponding registered flow
Sourcepub async fn enqueue(&self, msg: KaspadMessage) -> Result<(), ProtocolError>
pub async fn enqueue(&self, msg: KaspadMessage) -> Result<(), ProtocolError>
Enqueues a locally-originated message to be sent to the network peer
Sourcepub async fn try_sending_reject_message(&self, err: &ProtocolError)
pub async fn try_sending_reject_message(&self, err: &ProtocolError)
Based on the type of the protocol error, tries sending a reject message before shutting down the connection
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Router
impl !RefUnwindSafe for Router
impl Send for Router
impl Sync for Router
impl Unpin for Router
impl !UnwindSafe for Router
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<S> CastArc for Swhere
S: CastFromSync + ?Sized,
impl<S> CastArc for Swhere
S: CastFromSync + ?Sized,
Source§impl<T> CastFrom for Twhere
T: Any + 'static,
impl<T> CastFrom for Twhere
T: Any + 'static,
Source§fn ref_any(&self) -> &(dyn Any + 'static)
fn ref_any(&self) -> &(dyn Any + 'static)
Any, which is backed by the type implementing this trait.Source§fn mut_any(&mut self) -> &mut (dyn Any + 'static)
fn mut_any(&mut self) -> &mut (dyn Any + 'static)
Any, which is backed by the type implementing this trait.Source§impl<T> CastFromSync for T
impl<T> CastFromSync 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> 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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request