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§
Sourceconst MAXIMUM_PUZZLE_REQUESTS_PER_INTERVAL: usize = 5usize
const MAXIMUM_PUZZLE_REQUESTS_PER_INTERVAL: usize = 5usize
The maximum number of puzzle requests per interval.
Sourceconst MAXIMUM_BLOCK_REQUESTS_PER_INTERVAL: usize = 256usize
const MAXIMUM_BLOCK_REQUESTS_PER_INTERVAL: usize = 256usize
The maximum number of block requests per interval.
Sourceconst PING_SLEEP_IN_SECS: u64 = 20u64
const PING_SLEEP_IN_SECS: u64 = 20u64
The duration in seconds to sleep in between ping requests with a connected peer.
Sourceconst MESSAGE_LIMIT_TIME_FRAME_IN_SECS: i64 = 5i64
const MESSAGE_LIMIT_TIME_FRAME_IN_SECS: i64 = 5i64
The time frame to enforce the MESSAGE_LIMIT
.
Sourceconst MESSAGE_LIMIT: usize = 500usize
const MESSAGE_LIMIT: usize = 500usize
The maximum number of messages accepted within MESSAGE_LIMIT_TIME_FRAME_IN_SECS
.
Required Methods§
Sourcefn is_valid_message_version(&self, message_version: u32) -> bool
fn is_valid_message_version(&self, message_version: u32) -> bool
Returns true
if the message version is valid.
Sourcefn block_request(&self, peer_ip: SocketAddr, _message: BlockRequest) -> bool
fn block_request(&self, peer_ip: SocketAddr, _message: BlockRequest) -> bool
Handles a BlockRequest
message.
Sourcefn block_response(&self, peer_ip: SocketAddr, _blocks: Vec<Block<N>>) -> bool
fn block_response(&self, peer_ip: SocketAddr, _blocks: Vec<Block<N>>) -> bool
Handles a BlockResponse
message.
Sourcefn ping(&self, peer_ip: SocketAddr, message: Ping<N>) -> bool
fn ping(&self, peer_ip: SocketAddr, message: Ping<N>) -> bool
Handles a Ping
message.
Sourcefn pong(&self, peer_ip: SocketAddr, _message: Pong) -> bool
fn pong(&self, peer_ip: SocketAddr, _message: Pong) -> bool
Sleeps for a period and then sends a Ping
message to the peer.
Sourcefn puzzle_request(&self, peer_ip: SocketAddr) -> bool
fn puzzle_request(&self, peer_ip: SocketAddr) -> bool
Handles a PuzzleRequest
message.
Sourcefn puzzle_response(
&self,
peer_ip: SocketAddr,
_epoch_hash: N::BlockHash,
_header: Header<N>,
) -> bool
fn puzzle_response( &self, peer_ip: SocketAddr, _epoch_hash: N::BlockHash, _header: Header<N>, ) -> bool
Handles a PuzzleResponse
message.
Sourcefn 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_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.
Sourcefn 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,
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§
Sourcefn is_within_sync_leniency(&self) -> bool
fn is_within_sync_leniency(&self) -> bool
Is the node synced enough to process unconfirmed transactions and solutions?
Sourcefn 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 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.
Sourcefn peer_request(&self, peer_ip: SocketAddr) -> bool
fn peer_request(&self, peer_ip: SocketAddr) -> bool
Handles a PeerRequest
message.
Sourcefn peer_response(&self, _peer_ip: SocketAddr, peers: &[SocketAddr]) -> bool
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.