Skip to content

Commit

Permalink
feat(budget): allow feedback from manual budgets
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed Nov 30, 2023
1 parent 03dad1d commit f2bbe0d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions graph-gateway/src/client_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,6 @@ async fn handle_client_query_inner(
.map(|c| USD(c.fee.0 / grt_per_usd.0))
.collect();
let mut budget = ctx.budgeter.budget(budget_query_count, &candidate_fees);
let ignore_budget_feedback = user_settings.budget.is_some();
if let Some(user_budget) = user_settings.budget {
// Security: Consumers can and will set their budget to unreasonably high values.
// This `.min` prevents the budget from being set far beyond what it would be
Expand Down Expand Up @@ -679,13 +678,11 @@ async fn handle_client_query_inner(
match outcome_rx.recv().await {
Some(Err(_)) | None => (),
Some(Ok(outcome)) => {
if !ignore_budget_feedback {
let total_indexer_fees = USD(total_indexer_fees.0 / grt_per_usd.0);
let _ = ctx.budgeter.feedback.send(budgets::Feedback {
fees: total_indexer_fees,
query_count: budget_query_count,
});
}
let total_indexer_fees = USD(total_indexer_fees.0 / grt_per_usd.0);
let _ = ctx.budgeter.feedback.send(budgets::Feedback {
fees: total_indexer_fees,
query_count: budget_query_count,
});

return Ok(outcome);
}
Expand Down

0 comments on commit f2bbe0d

Please sign in to comment.