Skip to content

Commit

Permalink
v1.17: Treat super low staked as unstaked in streamer QOS (backport of
Browse files Browse the repository at this point in the history
…#701) (#732)

* Treat super low staked as unstaked in streamer QOS (#701)
  • Loading branch information
mergify[bot] authored and yihau committed Apr 11, 2024
1 parent f6c2ad9 commit 3a7c033
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions streamer/src/nonblocking/quic.rs
Expand Up @@ -495,6 +495,16 @@ async fn setup_connection(
stats.clone(),
),
|(pubkey, stake, total_stake, max_stake, min_stake)| {
// The heuristic is that the stake should be large engouh to have 1 stream pass throuh within one throttle
// interval during which we allow max MAX_STREAMS_PER_100MS streams.
let min_stake_ratio = 1_f64 / MAX_STREAMS_PER_100MS as f64;
let stake_ratio = stake as f64 / total_stake as f64;
let stake = if stake_ratio < min_stake_ratio {
// If it is a staked connection with ultra low stake ratio, treat it as unstaked.
0
} else {
stake
};
NewConnectionHandlerParams {
packet_sender,
remote_pubkey: Some(pubkey),
Expand Down

0 comments on commit 3a7c033

Please sign in to comment.