From a977e669f54d05ba1e73f308a509566e7af50783 Mon Sep 17 00:00:00 2001 From: Theo Butler Date: Mon, 9 Dec 2024 14:39:42 -0500 Subject: [PATCH] refactor: move network errors to snapshot mod --- src/network.rs | 4 +--- src/network/errors.rs | 17 ----------------- src/network/service.rs | 6 +++--- src/network/snapshot.rs | 19 ++++++++++++++++++- src/network/subgraph_processing.rs | 2 +- 5 files changed, 23 insertions(+), 25 deletions(-) delete mode 100644 src/network/errors.rs diff --git a/src/network.rs b/src/network.rs index 54788686..03bb9051 100644 --- a/src/network.rs +++ b/src/network.rs @@ -1,10 +1,8 @@ -pub use errors::{DeploymentError, SubgraphError}; pub use service::{NetworkService, ResolvedSubgraphInfo}; -pub use snapshot::{Indexing, IndexingId}; +pub use snapshot::{DeploymentError, Indexing, IndexingId, SubgraphError}; use thegraph_graphql_http::graphql::{IntoDocument as _, IntoDocumentWithVariables}; pub mod cost_model; -mod errors; pub mod host_filter; mod indexer_processing; pub mod indexing_progress; diff --git a/src/network/errors.rs b/src/network/errors.rs deleted file mode 100644 index 060d61b0..00000000 --- a/src/network/errors.rs +++ /dev/null @@ -1,17 +0,0 @@ -#[derive(Clone, Debug, thiserror::Error)] -pub enum SubgraphError { - /// No allocations were found for the subgraph. - #[error("no allocations")] - NoAllocations, - - /// All subgraph versions were marked as invalid. - #[error("no valid versions")] - NoValidVersions, -} - -#[derive(Clone, Debug, thiserror::Error)] -pub enum DeploymentError { - /// No allocations were found for the subgraph. - #[error("no allocations")] - NoAllocations, -} diff --git a/src/network/service.rs b/src/network/service.rs index c5927896..626e4803 100644 --- a/src/network/service.rs +++ b/src/network/service.rs @@ -17,20 +17,20 @@ use tokio::{sync::watch, time::MissedTickBehavior}; use super::{ cost_model::CostModelResolver, - errors::{DeploymentError, SubgraphError}, host_filter::HostFilter, indexer_processing::{self, IndexerRawInfo}, indexing_progress::IndexingProgressResolver, poi_filter::PoiFilter, + pre_processing, snapshot::{self, Indexing, IndexingId, NetworkTopologySnapshot}, subgraph_client::Client as SubgraphClient, - subgraph_processing::{DeploymentInfo, SubgraphInfo}, + subgraph_processing::{self, DeploymentInfo, SubgraphInfo}, version_filter::{MinimumVersionRequirements, VersionFilter}, + DeploymentError, SubgraphError, }; use crate::{ config::{BlockedIndexer, BlockedPoi}, errors::UnavailableReason, - network::{pre_processing, subgraph_processing}, }; /// Subgraph resolution information returned by the [`NetworkService`]. diff --git a/src/network/snapshot.rs b/src/network/snapshot.rs index 21244642..30750c74 100644 --- a/src/network/snapshot.rs +++ b/src/network/snapshot.rs @@ -13,7 +13,6 @@ use url::Url; use crate::{ errors::UnavailableReason, network::{ - errors::{DeploymentError, SubgraphError}, indexer_processing::ResolvedIndexerInfo, subgraph_processing::{DeploymentInfo, SubgraphInfo}, }, @@ -141,6 +140,24 @@ pub struct NetworkTopologySnapshot { pub deployments: HashMap>, } +#[derive(Clone, Debug, thiserror::Error)] +pub enum SubgraphError { + /// No allocations were found for the subgraph. + #[error("no allocations")] + NoAllocations, + + /// All subgraph versions were marked as invalid. + #[error("no valid versions")] + NoValidVersions, +} + +#[derive(Clone, Debug, thiserror::Error)] +pub enum DeploymentError { + /// No allocations were found for the subgraph. + #[error("no allocations")] + NoAllocations, +} + /// Construct the [`NetworkTopologySnapshot`] from the indexers and subgraphs information. pub fn new_from( indexers_info: HashMap>, diff --git a/src/network/subgraph_processing.rs b/src/network/subgraph_processing.rs index 16a821b0..d2c86d1e 100644 --- a/src/network/subgraph_processing.rs +++ b/src/network/subgraph_processing.rs @@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet}; use thegraph_core::{alloy::primitives::BlockNumber, DeploymentId, IndexerId, SubgraphId}; -use crate::network::errors::{DeploymentError, SubgraphError}; +use crate::network::{DeploymentError, SubgraphError}; /// Internal representation of the fetched subgraph information. ///