From c44d47ea2206c4f75c7f42943b0a085efb9b18c7 Mon Sep 17 00:00:00 2001 From: Jannis Pohlmann Date: Wed, 25 Oct 2023 10:41:03 +0200 Subject: [PATCH] fix: update to latest subgraph client API changes --- common/src/indexer_service/http/config.rs | 9 +++++++ .../indexer_service/http/indexer_service.rs | 26 +++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/common/src/indexer_service/http/config.rs b/common/src/indexer_service/http/config.rs index a408c4bb9..a008b4367 100644 --- a/common/src/indexer_service/http/config.rs +++ b/common/src/indexer_service/http/config.rs @@ -2,6 +2,7 @@ use std::net::SocketAddr; use alloy_primitives::Address; use serde::{Deserialize, Serialize}; +use toolshed::thegraph::DeploymentId; #[derive(Clone, Debug, Deserialize, Serialize)] pub struct DatabaseConfig { @@ -10,12 +11,14 @@ pub struct DatabaseConfig { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct NetworkSubgraphConfig { + pub deployment: Option, pub query_url: String, pub syncing_interval: u64, } #[derive(Clone, Debug, Deserialize, Serialize)] pub struct EscrowSubgraphConfig { + pub deployment: Option, pub query_url: String, pub syncing_interval: u64, } @@ -32,11 +35,17 @@ pub struct IndexerServiceConfig { pub indexer: IndexerConfig, pub server: ServerConfig, pub database: DatabaseConfig, + pub graph_node: Option, pub network_subgraph: NetworkSubgraphConfig, pub escrow_subgraph: EscrowSubgraphConfig, pub graph_network: GraphNetworkConfig, } +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct GraphNodeConfig { + pub query_base_url: String, +} + #[derive(Clone, Debug, Deserialize, Serialize)] pub struct GraphNetworkConfig { pub id: u64, diff --git a/common/src/indexer_service/http/indexer_service.rs b/common/src/indexer_service/http/indexer_service.rs index fb3935b5e..7dd24cda5 100644 --- a/common/src/indexer_service/http/indexer_service.rs +++ b/common/src/indexer_service/http/indexer_service.rs @@ -20,7 +20,7 @@ use toolshed::thegraph::DeploymentId; use crate::{ prelude::{ attestation_signers, dispute_manager, escrow_accounts, indexer_allocations, - AttestationSigner, SubgraphClient, + AttestationSigner, DeploymentDetails, SubgraphClient, }, tap_manager::TapManager, }; @@ -141,8 +141,16 @@ impl IndexerService { I: IndexerServiceImpl + Sync + Send + 'static, { let network_subgraph = Box::leak(Box::new(SubgraphClient::new( - "network-subgraph", - &options.config.network_subgraph.query_url, + options + .config + .graph_node + .as_ref() + .zip(options.config.network_subgraph.deployment) + .map(|(graph_node, deployment)| { + DeploymentDetails::for_graph_node(&graph_node.query_base_url, deployment) + }) + .transpose()?, + DeploymentDetails::for_query_url(&options.config.network_subgraph.query_url)?, )?)); // Identify the dispute manager for the configured network @@ -170,8 +178,16 @@ impl IndexerService { ); let escrow_subgraph = Box::leak(Box::new(SubgraphClient::new( - "escrow-subgraph", - &options.config.escrow_subgraph.query_url, + options + .config + .graph_node + .as_ref() + .zip(options.config.escrow_subgraph.deployment) + .map(|(graph_node, deployment)| { + DeploymentDetails::for_graph_node(&graph_node.query_base_url, deployment) + }) + .transpose()?, + DeploymentDetails::for_query_url(&options.config.escrow_subgraph.query_url)?, )?)); let escrow_accounts = escrow_accounts(