Document how outbound handshakes are rate-limited (#7976)
This commit is contained in:
parent
382fb3775a
commit
ca062d04d4
|
|
@ -368,7 +368,8 @@ where
|
||||||
/// Zebra resists distributed denial of service attacks by making sure that
|
/// Zebra resists distributed denial of service attacks by making sure that
|
||||||
/// new peer connections are initiated at least
|
/// new peer connections are initiated at least
|
||||||
/// [`MIN_OUTBOUND_PEER_CONNECTION_INTERVAL`][constants::MIN_OUTBOUND_PEER_CONNECTION_INTERVAL]
|
/// [`MIN_OUTBOUND_PEER_CONNECTION_INTERVAL`][constants::MIN_OUTBOUND_PEER_CONNECTION_INTERVAL]
|
||||||
/// apart.
|
/// apart. If `next()` has recently provided a peer, then its future will sleep
|
||||||
|
/// until the rate-limit has passed.
|
||||||
///
|
///
|
||||||
/// [`Responded`]: crate::PeerAddrState::Responded
|
/// [`Responded`]: crate::PeerAddrState::Responded
|
||||||
pub async fn next(&mut self) -> Option<MetaAddr> {
|
pub async fn next(&mut self) -> Option<MetaAddr> {
|
||||||
|
|
|
||||||
|
|
@ -870,6 +870,12 @@ where
|
||||||
|
|
||||||
// Spawn each handshake or crawl into an independent task, so handshakes can make
|
// Spawn each handshake or crawl into an independent task, so handshakes can make
|
||||||
// progress while crawls are running.
|
// progress while crawls are running.
|
||||||
|
//
|
||||||
|
// # Concurrency
|
||||||
|
//
|
||||||
|
// The peer crawler must be able to make progress even if some handshakes are
|
||||||
|
// rate-limited. So the async mutex and next peer timeout are awaited inside the
|
||||||
|
// spawned task.
|
||||||
let handshake_or_crawl_handle = tokio::spawn(
|
let handshake_or_crawl_handle = tokio::spawn(
|
||||||
async move {
|
async move {
|
||||||
// Try to get the next available peer for a handshake.
|
// Try to get the next available peer for a handshake.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue