Skip to content

Commit

Permalink
fix: ignore budget feedback when using manual budget
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed Oct 8, 2023
1 parent f241e90 commit 23fa435
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions graph-gateway/src/client_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ async fn handle_client_query_inner(
// For budgeting purposes, pick the latest deployment.
let budget_deployment = deployments.last().unwrap().id;
let mut budget: USD = ctx.budgeter.budget(&budget_deployment, budget_query_count);
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 @@ -689,17 +690,19 @@ async fn handle_client_query_inner(
Some(Err(IndexerError::BlockError(_))) => latest_unresolved += 1,
Some(Err(_)) | None => (),
Some(Ok(outcome)) => {
let total_indexer_fees: USD = ctx
.isa_state
.latest()
.network_params
.grt_to_usd(total_indexer_fees)
.unwrap();
let _ = ctx.budgeter.feedback.send(budgets::Feedback {
deployment: budget_deployment,
fees: total_indexer_fees,
query_count: budget_query_count,
});
if !ignore_budget_feedback {
let total_indexer_fees: USD = ctx
.isa_state
.latest()
.network_params
.grt_to_usd(total_indexer_fees)
.unwrap();
let _ = ctx.budgeter.feedback.send(budgets::Feedback {
deployment: budget_deployment,
fees: total_indexer_fees,
query_count: budget_query_count,
});
}

return Ok(outcome);
}
Expand Down

0 comments on commit 23fa435

Please sign in to comment.