Skip to main content

next_reconnect_peer

Function next_reconnect_peer 

Source
pub(crate) async fn next_reconnect_peer(
    next_peer_service: &mut RateLimitOnYield<Buffer<BoxService<AddressBookRequest, AddressBookResponse, BoxError>, AddressBookRequest>, AddressBookResponse>,
) -> Option<MetaAddr>
Expand description

Returns the next candidate for a connection attempt, if any are available.

Returns peers in reconnection order, based on AddressBook::reconnection_peers.

Skips peers that have recently been active, attempted, or failed.

§Correctness

AttemptPending peers will become Responded if they respond, or become Failed if they time out or provide a bad response.

Live Responded peers will stay live if they keep responding, or become a reconnection candidate if they stop responding.

§Security

Zebra resists distributed denial of service attacks by making sure that new peer connections are initiated at least MIN_OUTBOUND_PEER_CONNECTION_INTERVAL apart. If a peer was recently provided, then this future will sleep until the rate-limit has passed.