Skip to content

Commit

Permalink
refactor: move network errors to snapshot mod
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed Dec 9, 2024
1 parent 85ef06e commit a977e66
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 25 deletions.
4 changes: 1 addition & 3 deletions src/network.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
17 changes: 0 additions & 17 deletions src/network/errors.rs

This file was deleted.

6 changes: 3 additions & 3 deletions src/network/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
Expand Down
19 changes: 18 additions & 1 deletion src/network/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use url::Url;
use crate::{
errors::UnavailableReason,
network::{
errors::{DeploymentError, SubgraphError},
indexer_processing::ResolvedIndexerInfo,
subgraph_processing::{DeploymentInfo, SubgraphInfo},
},
Expand Down Expand Up @@ -141,6 +140,24 @@ pub struct NetworkTopologySnapshot {
pub deployments: HashMap<DeploymentId, Result<Deployment, DeploymentError>>,
}

#[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<IndexerId, Result<ResolvedIndexerInfo, UnavailableReason>>,
Expand Down
2 changes: 1 addition & 1 deletion src/network/subgraph_processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down

0 comments on commit a977e66

Please sign in to comment.