Trait snarkos_node_router::Outbound

source ·
pub trait Outbound<N: Network>: Writing<Message = Message<N>> {
    // Required methods
    fn router(&self) -> &Router<N>;
    fn is_block_synced(&self) -> bool;
    fn num_blocks_behind(&self) -> u32;

    // Provided methods
    fn send_ping(
        &self,
        peer_ip: SocketAddr,
        block_locators: Option<BlockLocators<N>>,
    ) { ... }
    fn send(
        &self,
        peer_ip: SocketAddr,
        message: Message<N>,
    ) -> Option<Receiver<Result<()>>> { ... }
    fn propagate(&self, message: Message<N>, excluded_peers: &[SocketAddr]) { ... }
    fn propagate_to_validators(
        &self,
        message: Message<N>,
        excluded_peers: &[SocketAddr],
    ) { ... }
    fn can_send(&self, peer_ip: SocketAddr, message: &Message<N>) -> bool { ... }
}

Required Methods§

source

fn router(&self) -> &Router<N>

Returns a reference to the router.

source

fn is_block_synced(&self) -> bool

Returns true if the node is synced up to the latest block (within the given tolerance).

source

fn num_blocks_behind(&self) -> u32

Returns the number of blocks this node is behind the greatest peer height.

Provided Methods§

source

fn send_ping( &self, peer_ip: SocketAddr, block_locators: Option<BlockLocators<N>>, )

Sends a “Ping” message to the given peer.

source

fn send( &self, peer_ip: SocketAddr, message: Message<N>, ) -> Option<Receiver<Result<()>>>

Sends the given message to specified peer.

This function returns as soon as the message is queued to be sent, without waiting for the actual delivery; instead, the caller is provided with a oneshot::Receiver which can be used to determine when and whether the message has been delivered.

source

fn propagate(&self, message: Message<N>, excluded_peers: &[SocketAddr])

Sends the given message to every connected peer, excluding the sender and any specified peer IPs.

source

fn propagate_to_validators( &self, message: Message<N>, excluded_peers: &[SocketAddr], )

Sends the given message to every connected validator, excluding the sender and any specified IPs.

source

fn can_send(&self, peer_ip: SocketAddr, message: &Message<N>) -> bool

Returns true if the message can be sent.

Object Safety§

This trait is not object safe.

Implementors§