Skip to content

Commit

Permalink
fix(budget): potential div by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed Sep 6, 2023
1 parent fa2b38a commit 11cdbaf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions graph-gateway/src/budgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ impl Actor {
}

fn revise_budget(&mut self) {
let surplus = self
.query_fees_target
.saturating_sub(self.recent_fees / USD::try_from(self.recent_query_count).unwrap());
let surplus = self.query_fees_target.saturating_sub(
self.recent_fees / USD::try_from(self.recent_query_count.max(1)).unwrap(),
);
self.recent_fees = USD::zero();
self.recent_query_count = 0;

Expand Down

0 comments on commit 11cdbaf

Please sign in to comment.