pub struct Ping<N: Network> { /* private fields */ }
Expand description
Manages sending Ping messages to all connected peers.
Implementations§
Source§impl<N: Network> Ping<N>
impl<N: Network> Ping<N>
Sourcepub fn new(router: Router<N>, block_locators: BlockLocators<N>) -> Self
pub fn new(router: Router<N>, block_locators: BlockLocators<N>) -> Self
Create a new instance of the ping logic. There should only be one per node.
§Usage
Initialize this with the most up-to-date block locators and call update_block_locators, whenever a new block is received/created.
Sourcepub fn new_nosync(router: Router<N>) -> Self
pub fn new_nosync(router: Router<N>) -> Self
Same as Self::new
but for nodes that peers cannot sync from
such as provers.
Sourcepub fn on_pong_received(&self, peer_ip: SocketAddr)
pub fn on_pong_received(&self, peer_ip: SocketAddr)
Notify the ping logic that we received a Pong response.
Sourcepub fn on_peer_connected(&self, peer_ip: SocketAddr)
pub fn on_peer_connected(&self, peer_ip: SocketAddr)
Notify the ping logic that a new peer connected.
Sourcepub fn update_block_locators(&self, locators: BlockLocators<N>)
pub fn update_block_locators(&self, locators: BlockLocators<N>)
Notify the ping logic that new blocks were created or synced.
Auto Trait Implementations§
impl<N> Freeze for Ping<N>
impl<N> !RefUnwindSafe for Ping<N>
impl<N> Send for Ping<N>
impl<N> Sync for Ping<N>
impl<N> Unpin for Ping<N>
impl<N> !UnwindSafe for Ping<N>
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
Mutably borrows from an owned value. Read more
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>
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 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>
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