Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow some minimum number of streams for a staked connection - v1.17 #34894

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion streamer/src/nonblocking/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,9 +695,13 @@ fn max_streams_for_connection_in_100ms(
.apply_to(MAX_STREAMS_PER_100MS)
.saturating_div(MAX_UNSTAKED_CONNECTIONS as u64)
} else {
const MIN_STAKED_STREAMS: u64 = 8;
let max_total_staked_streams: u64 = MAX_STREAMS_PER_100MS
- Percentage::from(MAX_UNSTAKED_STREAMS_PERCENT).apply_to(MAX_STREAMS_PER_100MS);
((max_total_staked_streams as f64 / total_stake as f64) * stake as f64) as u64
std::cmp::max(
MIN_STAKED_STREAMS,
((max_total_staked_streams as f64 / total_stake as f64) * stake as f64) as u64,
)
}
}

Expand Down Expand Up @@ -2063,5 +2067,12 @@ pub mod test {
max_streams_for_connection_in_100ms(ConnectionPeerType::Staked, 1000, 10000),
4000
);

// max staked streams = 50K packets per ms * 80% = 40K
// minimum staked streams.
assert_eq!(
max_streams_for_connection_in_100ms(ConnectionPeerType::Staked, 1, 50000),
8
);
}
}