diff --git a/streamer/src/nonblocking/quic.rs b/streamer/src/nonblocking/quic.rs index ddf4005c432e3d..630981d61731f6 100644 --- a/streamer/src/nonblocking/quic.rs +++ b/streamer/src/nonblocking/quic.rs @@ -1,7 +1,8 @@ use { crate::{ nonblocking::stream_throttle::{ - ConnectionStreamCounter, StakedStreamLoadEMA, STREAM_STOP_CODE_THROTTLING, + ConnectionStreamCounter, StakedStreamLoadEMA, MAX_STREAMS_PER_MS, + STREAM_STOP_CODE_THROTTLING, }, quic::{configure_server, QuicServerError, StreamStats}, streamer::StakedNodes, @@ -501,7 +502,14 @@ async fn setup_connection( ), |(pubkey, stake, total_stake, max_stake, min_stake)| { let peer_type = if stake > 0 { - ConnectionPeerType::Staked(stake) + // If it is a staked connection with ultra low stake ratio, treat it as unstaked. + let min_ratio = 1_f64 / (MAX_STREAMS_PER_MS * 100) as f64; + let stake_ratio = stake as f64 / total_stake as f64; + if stake_ratio < min_ratio { + ConnectionPeerType::Unstaked + } else { + ConnectionPeerType::Staked(stake) + } } else { ConnectionPeerType::Unstaked }; diff --git a/streamer/src/nonblocking/stream_throttle.rs b/streamer/src/nonblocking/stream_throttle.rs index 8fda63271816e6..745d4a2c23e03e 100644 --- a/streamer/src/nonblocking/stream_throttle.rs +++ b/streamer/src/nonblocking/stream_throttle.rs @@ -12,7 +12,7 @@ use { }; /// Limit to 250K PPS -const MAX_STREAMS_PER_MS: u64 = 250; +pub const MAX_STREAMS_PER_MS: u64 = 250; const MAX_UNSTAKED_STREAMS_PERCENT: u64 = 20; const STREAM_THROTTLING_INTERVAL_MS: u64 = 100; pub const STREAM_STOP_CODE_THROTTLING: u32 = 15;