Skip to content

Commit

Permalink
fix: handling of null timestamp from probe
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed Mar 12, 2024
1 parent b9fb417 commit 8bb33f4
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions graph-gateway/src/client_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
time::{Duration, Instant},
};

use alloy_primitives::{Address, BlockNumber};
use alloy_primitives::{Address, BlockHash, BlockNumber};
use alloy_sol_types::Eip712Domain;
use anyhow::anyhow;
use axum::{
Expand Down Expand Up @@ -828,7 +828,13 @@ fn rewrite_response(
}
#[derive(Deserialize)]
struct Meta {
block: Block,
block: MaybeBlock,
}
#[derive(Deserialize)]
struct MaybeBlock {
number: BlockNumber,
hash: BlockHash,
timestamp: Option<u64>,
}
let mut payload: GQLResponseBody<ProbedData> =
serde_json::from_str(response).map_err(|err| IndexerError::BadResponse(err.to_string()))?;
Expand All @@ -843,7 +849,13 @@ fn rewrite_response(
.data
.as_mut()
.and_then(|data| data.probe.take())
.map(|meta| meta.block);
.and_then(|meta| {
Some(Block {
number: meta.block.number,
hash: meta.block.hash,
timestamp: meta.block.timestamp?,
})
});
let client_response = serde_json::to_string(&payload).unwrap();
Ok((client_response, payload.errors, block))
}
Expand Down

0 comments on commit 8bb33f4

Please sign in to comment.