Skip to content

Commit

Permalink
remove connection count related changes -- they are unrelated to this PR
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunwangs committed Apr 22, 2024
1 parent 5fcb3d1 commit 112af05
Showing 1 changed file with 15 additions and 41 deletions.
56 changes: 15 additions & 41 deletions streamer/src/nonblocking/stream_throttle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@ pub mod test {
assert_eq!(
load_ema.available_load_capacity_in_throttling_duration(
ConnectionPeerType::Unstaked,
10000,
1,
10000
),
10
);
Expand Down Expand Up @@ -287,8 +286,7 @@ pub mod test {
assert_eq!(
load_ema.available_load_capacity_in_throttling_duration(
ConnectionPeerType::Staked(15),
10000,
1,
10000
),
30
);
Expand All @@ -298,8 +296,7 @@ pub mod test {
assert_eq!(
load_ema.available_load_capacity_in_throttling_duration(
ConnectionPeerType::Staked(1000),
10000,
1,
10000
),
2000
);
Expand All @@ -310,8 +307,7 @@ pub mod test {
assert_eq!(
load_ema.available_load_capacity_in_throttling_duration(
ConnectionPeerType::Staked(15),
10000,
1,
10000
),
120
);
Expand All @@ -321,8 +317,7 @@ pub mod test {
assert_eq!(
load_ema.available_load_capacity_in_throttling_duration(
ConnectionPeerType::Staked(1000),
10000,
1,
10000
),
8000
);
Expand All @@ -334,8 +329,7 @@ pub mod test {
assert_eq!(
load_ema.available_load_capacity_in_throttling_duration(
ConnectionPeerType::Staked(15),
10000,
1,
10000
),
120
);
Expand All @@ -344,8 +338,7 @@ pub mod test {
assert_eq!(
load_ema.available_load_capacity_in_throttling_duration(
ConnectionPeerType::Staked(1000),
10000,
1,
10000
),
8000
);
Expand All @@ -355,8 +348,7 @@ pub mod test {
assert_eq!(
load_ema.available_load_capacity_in_throttling_duration(
ConnectionPeerType::Staked(1),
40000,
1,
40000
),
load_ema
.max_unstaked_load_in_throttling_window
Expand Down Expand Up @@ -386,8 +378,7 @@ pub mod test {
assert!(
(46u64..=47).contains(&load_ema.available_load_capacity_in_throttling_duration(
ConnectionPeerType::Staked(15),
10000,
1,
10000
))
);

Expand All @@ -396,8 +387,7 @@ pub mod test {
assert!((3124u64..=3125).contains(
&load_ema.available_load_capacity_in_throttling_duration(
ConnectionPeerType::Staked(1000),
10000,
1,
10000
)
));

Expand All @@ -407,8 +397,7 @@ pub mod test {
assert!(
(92u64..=94).contains(&load_ema.available_load_capacity_in_throttling_duration(
ConnectionPeerType::Staked(15),
10000,
1,
10000
))
);

Expand All @@ -417,8 +406,7 @@ pub mod test {
assert!((6248u64..=6250).contains(
&load_ema.available_load_capacity_in_throttling_duration(
ConnectionPeerType::Staked(1000),
10000,
1,
10000
)
));

Expand All @@ -429,8 +417,7 @@ pub mod test {
assert_eq!(
load_ema.available_load_capacity_in_throttling_duration(
ConnectionPeerType::Staked(15),
10000,
1,
10000
),
150
);
Expand All @@ -439,30 +426,17 @@ pub mod test {
assert_eq!(
load_ema.available_load_capacity_in_throttling_duration(
ConnectionPeerType::Staked(1000),
10000,
1,
10000
),
10000
);

// function = ((12.5K * 12.5K) / 25% of 12.5K) * stake / total_stake / connection_count
// as there are more than 1 connection from the staked node
assert_eq!(
load_ema.available_load_capacity_in_throttling_duration(
ConnectionPeerType::Staked(1000),
10000,
4,
),
10000 / 4
);

// At 1/400000 stake weight, and minimum load, it should still allow
// max_unstaked_load_in_throttling_window + 1 streams.
assert_eq!(
load_ema.available_load_capacity_in_throttling_duration(
ConnectionPeerType::Staked(1),
400000,
1,
400000
),
load_ema
.max_unstaked_load_in_throttling_window
Expand Down

0 comments on commit 112af05

Please sign in to comment.