Skip to content

Commit

Permalink
fix: indexer query fee
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed Feb 16, 2024
1 parent 85b4dbb commit 3ba18b9
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions graph-gateway/src/client_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,30 +694,33 @@ async fn handle_indexer_query(
let indexing = selection.indexing;
let deployment = indexing.deployment.to_string();

tracing::info!(
target: reports::INDEXER_QUERY_TARGET,
%deployment,
url = %selection.url,
blocks_behind = selection.blocks_behind,
fee_grt = (selection.fee as f64 * 1e-18) as f32,
subgraph_chain = %ctx.deployment.manifest.network,
);

let sent_optimistic_query = optimistic_query.is_some();
let optimistic_response = match optimistic_query {
Some(query) => handle_indexer_query_inner(&mut ctx, selection.clone(), query)
.await
.ok(),
None => None,
};
let failed_optimistic_response = optimistic_response.is_none();
let result = match optimistic_response {
Some(response) => Ok(response),
None => handle_indexer_query_inner(&mut ctx, selection, deterministic_query).await,
None => handle_indexer_query_inner(&mut ctx, selection.clone(), deterministic_query).await,
};
METRICS.indexer_query.check(&[&deployment], &result);

let mut fee_grt = selection.fee;
if sent_optimistic_query && failed_optimistic_response {
fee_grt *= 2;
}

let latency_ms = ctx.response_time.as_millis() as u32;
tracing::info!(
target: reports::INDEXER_QUERY_TARGET,
%deployment,
url = %selection.url,
blocks_behind = selection.blocks_behind,
fee_grt = (fee_grt as f64 * 1e-18) as f32,
subgraph_chain = %ctx.deployment.manifest.network,
response_time_ms = latency_ms,
status_message = match &result {
Ok(_) => "200 OK".to_string(),
Expand Down

0 comments on commit 3ba18b9

Please sign in to comment.