Inbound

Trait Inbound 

Source
pub trait Inbound<N: Network>: Reading + Outbound<N> {
    const MAXIMUM_PUZZLE_REQUESTS_PER_INTERVAL: usize = 5usize;
    const MAXIMUM_BLOCK_REQUESTS_PER_INTERVAL: usize = 256usize;
    const PING_SLEEP_IN_SECS: u64 = 20u64;
    const MESSAGE_LIMIT_TIME_FRAME_IN_SECS: i64 = 5i64;
    const MESSAGE_LIMIT: usize = 500usize;
Show 13 methods // Required methods fn is_valid_message_version(&self, message_version: u32) -> bool; fn block_request(&self, peer_ip: SocketAddr, _message: BlockRequest) -> bool; fn block_response( &self, peer_ip: SocketAddr, _blocks: Vec<Block<N>>, ) -> bool; fn ping(&self, peer_ip: SocketAddr, message: Ping<N>) -> bool; fn pong(&self, peer_ip: SocketAddr, _message: Pong) -> bool; fn puzzle_request(&self, peer_ip: SocketAddr) -> bool; fn puzzle_response( &self, peer_ip: SocketAddr, _epoch_hash: N::BlockHash, _header: Header<N>, ) -> bool; fn unconfirmed_solution<'life0, 'async_trait>( &'life0 self, peer_ip: SocketAddr, serialized: UnconfirmedSolution<N>, solution: Solution<N>, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn unconfirmed_transaction<'life0, 'async_trait>( &'life0 self, peer_ip: SocketAddr, serialized: UnconfirmedTransaction<N>, _transaction: Transaction<N>, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; // Provided methods fn is_within_sync_leniency(&self) -> bool { ... } fn inbound<'life0, 'async_trait>( &'life0 self, peer_addr: SocketAddr, message: Message<N>, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: Sync + 'async_trait, 'life0: 'async_trait { ... } fn peer_request(&self, peer_ip: SocketAddr) -> bool { ... } fn peer_response(&self, _peer_ip: SocketAddr, peers: &[SocketAddr]) -> bool { ... }
}

Provided Associated Constants§

Source

const MAXIMUM_PUZZLE_REQUESTS_PER_INTERVAL: usize = 5usize

The maximum number of puzzle requests per interval.

Source

const MAXIMUM_BLOCK_REQUESTS_PER_INTERVAL: usize = 256usize

The maximum number of block requests per interval.

Source

const PING_SLEEP_IN_SECS: u64 = 20u64

The duration in seconds to sleep in between ping requests with a connected peer.

Source

const MESSAGE_LIMIT_TIME_FRAME_IN_SECS: i64 = 5i64

The time frame to enforce the MESSAGE_LIMIT.

Source

const MESSAGE_LIMIT: usize = 500usize

The maximum number of messages accepted within MESSAGE_LIMIT_TIME_FRAME_IN_SECS.

Required Methods§

Source

fn is_valid_message_version(&self, message_version: u32) -> bool

Returns true if the message version is valid.

Source

fn block_request(&self, peer_ip: SocketAddr, _message: BlockRequest) -> bool

Handles a BlockRequest message.

Source

fn block_response(&self, peer_ip: SocketAddr, _blocks: Vec<Block<N>>) -> bool

Handles a BlockResponse message.

Source

fn ping(&self, peer_ip: SocketAddr, message: Ping<N>) -> bool

Handles a Ping message.

Source

fn pong(&self, peer_ip: SocketAddr, _message: Pong) -> bool

Sleeps for a period and then sends a Ping message to the peer.

Source

fn puzzle_request(&self, peer_ip: SocketAddr) -> bool

Handles a PuzzleRequest message.

Source

fn puzzle_response( &self, peer_ip: SocketAddr, _epoch_hash: N::BlockHash, _header: Header<N>, ) -> bool

Handles a PuzzleResponse message.

Source

fn unconfirmed_solution<'life0, 'async_trait>( &'life0 self, peer_ip: SocketAddr, serialized: UnconfirmedSolution<N>, solution: Solution<N>, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handles an UnconfirmedSolution message.

Source

fn unconfirmed_transaction<'life0, 'async_trait>( &'life0 self, peer_ip: SocketAddr, serialized: UnconfirmedTransaction<N>, _transaction: Transaction<N>, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handles an UnconfirmedTransaction message.

Provided Methods§

Source

fn is_within_sync_leniency(&self) -> bool

Is the node synced enough to process unconfirmed transactions and solutions?

Source

fn inbound<'life0, 'async_trait>( &'life0 self, peer_addr: SocketAddr, message: Message<N>, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

Handles the inbound message from the peer. The returned value indicates whether the connection is still active, and errors causing a disconnect once they are propagated to the caller.

Source

fn peer_request(&self, peer_ip: SocketAddr) -> bool

Handles a PeerRequest message.

Source

fn peer_response(&self, _peer_ip: SocketAddr, peers: &[SocketAddr]) -> bool

Handles a PeerResponse message.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§