diff --git a/zebra-network/src/peer_set/initialize.rs b/zebra-network/src/peer_set/initialize.rs index aa3819ed..68312f1a 100644 --- a/zebra-network/src/peer_set/initialize.rs +++ b/zebra-network/src/peer_set/initialize.rs @@ -415,6 +415,16 @@ where .instrument(handshaker_span), ); } + + // Only spawn one inbound connection handshake per `MIN_PEER_CONNECTION_INTERVAL`. + // But clear out failed connections as fast as possible. + // + // If there is a flood of connections, + // this stops Zebra overloading the network with handshake data. + // + // Zebra can't control how many queued connections are waiting, + // but most OSes also limit the number of queued inbound connections on a listener port. + tokio::time::sleep(constants::MIN_PEER_CONNECTION_INTERVAL).await; } } }