Skip to content

Commit

Permalink
Fix determination of staked QUIC connections (solana-labs#34760)
Browse files Browse the repository at this point in the history
* Fix determination of staked QUIC connections

* address review comments

* review comments

* treat connections with zero stake as unstaked
  • Loading branch information
pgarg66 authored Jan 14, 2024
1 parent 9468996 commit f92275b
Show file tree
Hide file tree
Showing 3 changed files with 184 additions and 241 deletions.
12 changes: 6 additions & 6 deletions quic-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,21 @@ impl QuicConfig {
}

fn compute_max_parallel_streams(&self) -> usize {
let (client_type, stake, total_stake) =
let (client_type, total_stake) =
self.maybe_client_pubkey
.map_or((ConnectionPeerType::Unstaked, 0, 0), |pubkey| {
.map_or((ConnectionPeerType::Unstaked, 0), |pubkey| {
self.maybe_staked_nodes.as_ref().map_or(
(ConnectionPeerType::Unstaked, 0, 0),
(ConnectionPeerType::Unstaked, 0),
|stakes| {
let rstakes = stakes.read().unwrap();
rstakes.get_node_stake(&pubkey).map_or(
(ConnectionPeerType::Unstaked, 0, rstakes.total_stake()),
|stake| (ConnectionPeerType::Staked, stake, rstakes.total_stake()),
(ConnectionPeerType::Unstaked, rstakes.total_stake()),
|stake| (ConnectionPeerType::Staked(stake), rstakes.total_stake()),
)
},
)
});
compute_max_allowed_uni_streams(client_type, stake, total_stake)
compute_max_allowed_uni_streams(client_type, total_stake)
}

pub fn update_client_certificate(
Expand Down
Loading

0 comments on commit f92275b

Please sign in to comment.