Skip to content

Commit

Permalink
Merge in suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
NotGyro committed Apr 8, 2023
1 parent 1a6bc0b commit 13376da
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions consensus/service/src/api/client_api_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ impl ClientSessionTracking {
/// have existed for longer than this value will be dropped when this
/// method is called.
pub fn fail_tx_proposal(&mut self, now: Instant, tracking_window: Duration) -> usize {
self.tx_proposal_failures.retain(|past_failure| {
now.saturating_duration_since(*past_failure) <= tracking_window
});
self.tx_proposal_failures
.retain(|past_failure| now.saturating_duration_since(*past_failure) <= tracking_window);
self.tx_proposal_failures.push_back(now);
self.tx_proposal_failures.len()
}
Expand Down Expand Up @@ -145,11 +144,12 @@ impl ClientApiService {
let tracking_window = Duration::from_secs(60);
let mut tracker = self.tracked_sessions.lock().expect("Mutex poisoned");
if !tracker.contains(&session_id) {
tracker.put(session_id.clone(), ClientSessionTracking::new());
tracker.put(session_id.clone(), ClientSessionTracking::new());
}
let record =
tracker.get_mut(&session_id).expect("Session id {session_id} should be tracked.");

let record = tracker
.get_mut(&session_id)
.expect("Session id {session_id} should be tracked.");

let _recent_failure_count =
record.fail_tx_proposal(Instant::now(), tracking_window);
// Dropping the client after a limit has been reached will be
Expand Down

0 comments on commit 13376da

Please sign in to comment.