Skip to content

Commit a383f5e

Browse files
committed
graph: Remove unneeded methods from StatusStore trait
1 parent d444553 commit a383f5e

File tree

4 files changed

+10
-112
lines changed

4 files changed

+10
-112
lines changed

graph/src/components/store/traits.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use super::*;
99
use crate::blockchain::block_stream::{EntitySourceOperation, FirehoseCursor};
1010
use crate::blockchain::{BlockTime, ChainIdentifier, ExtendedBlockPtr};
1111
use crate::components::metrics::stopwatch::StopwatchMetrics;
12-
use crate::components::server::index_node::VersionInfo;
1312
use crate::components::subgraph::SubgraphVersionSwitchingMode;
1413
use crate::components::transaction_receipt;
1514
use crate::components::versions::ApiVersion;
@@ -687,25 +686,6 @@ pub trait StatusStore: Send + Sync + 'static {
687686

688687
fn status(&self, filter: status::Filter) -> Result<Vec<status::Info>, StoreError>;
689688

690-
/// Support for the explorer-specific API
691-
fn version_info(&self, version_id: &str) -> Result<VersionInfo, StoreError>;
692-
693-
/// Support for the explorer-specific API; note that `subgraph_id` must be
694-
/// the id of an entry in `subgraphs.subgraph`, not that of a deployment.
695-
/// The return values are the ids of the `subgraphs.subgraph_version` for
696-
/// the current and pending versions of the subgraph
697-
fn versions_for_subgraph_id(
698-
&self,
699-
subgraph_id: &str,
700-
) -> Result<(Option<String>, Option<String>), StoreError>;
701-
702-
/// Support for the explorer-specific API. Returns a vector of (name, version) of all
703-
/// subgraphs for a given deployment hash.
704-
fn subgraphs_for_deployment_hash(
705-
&self,
706-
deployment_hash: &str,
707-
) -> Result<Vec<(String, String)>, StoreError>;
708-
709689
/// A value of None indicates that the table is not available. Re-deploying
710690
/// the subgraph fixes this. It is undesirable to force everything to
711691
/// re-sync from scratch, so existing deployments will continue without a

store/postgres/src/primary.rs

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,8 @@ mod queries {
444444
use diesel::dsl::{exists, sql};
445445
use diesel::pg::PgConnection;
446446
use diesel::prelude::{
447-
BoolExpressionMethods, ExpressionMethods, JoinOnDsl, NullableExpressionMethods,
448-
OptionalExtension, QueryDsl, RunQueryDsl,
447+
ExpressionMethods, JoinOnDsl, NullableExpressionMethods, OptionalExtension, QueryDsl,
448+
RunQueryDsl,
449449
};
450450
use diesel::sql_types::Text;
451451
use graph::prelude::NodeId;
@@ -724,44 +724,6 @@ mod queries {
724724
.first::<(String, String)>(conn)
725725
.optional()?)
726726
}
727-
728-
pub(super) fn versions_for_subgraph_id(
729-
conn: &mut PgConnection,
730-
subgraph_id: &str,
731-
) -> Result<(Option<String>, Option<String>), StoreError> {
732-
Ok(s::table
733-
.select((s::current_version.nullable(), s::pending_version.nullable()))
734-
.filter(s::id.eq(subgraph_id))
735-
.first::<(Option<String>, Option<String>)>(conn)
736-
.optional()?
737-
.unwrap_or((None, None)))
738-
}
739-
740-
/// Returns all (subgraph_name, version) pairs for a given deployment hash.
741-
pub fn subgraphs_by_deployment_hash(
742-
conn: &mut PgConnection,
743-
deployment_hash: &str,
744-
) -> Result<Vec<(String, String)>, StoreError> {
745-
v::table
746-
.inner_join(
747-
s::table.on(v::id
748-
.nullable()
749-
.eq(s::current_version)
750-
.or(v::id.nullable().eq(s::pending_version))),
751-
)
752-
.filter(v::deployment.eq(&deployment_hash))
753-
.select((
754-
s::name,
755-
sql::<Text>(
756-
"(case when subgraphs.subgraph.pending_version = subgraphs.subgraph_version.id then 'pending'
757-
when subgraphs.subgraph.current_version = subgraphs.subgraph_version.id then 'current'
758-
else 'unused'
759-
end) as version",
760-
),
761-
))
762-
.get_results(conn)
763-
.map_err(Into::into)
764-
}
765727
}
766728

767729
/// A wrapper for a database connection that provides access to functionality
@@ -2117,21 +2079,6 @@ impl Mirror {
21172079
self.read(|conn| queries::version_info(conn, version))
21182080
}
21192081

2120-
pub fn versions_for_subgraph_id(
2121-
&self,
2122-
subgraph_id: &str,
2123-
) -> Result<(Option<String>, Option<String>), StoreError> {
2124-
self.read(|conn| queries::versions_for_subgraph_id(conn, subgraph_id))
2125-
}
2126-
2127-
/// Returns all (subgraph_name, version) pairs for a given deployment hash.
2128-
pub fn subgraphs_by_deployment_hash(
2129-
&self,
2130-
deployment_hash: &str,
2131-
) -> Result<Vec<(String, String)>, StoreError> {
2132-
self.read(|conn| queries::subgraphs_by_deployment_hash(conn, deployment_hash))
2133-
}
2134-
21352082
pub fn find_site_in_shard(
21362083
&self,
21372084
subgraph: &DeploymentHash,

store/postgres/src/store.rs

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ impl Store {
5050
pub fn block_store(&self) -> Arc<BlockStore> {
5151
self.block_store.cheap_clone()
5252
}
53+
54+
pub fn version_info(&self, version_id: &str) -> Result<VersionInfo, StoreError> {
55+
let mut info = self.subgraph_store.version_info(version_id)?;
56+
57+
info.total_ethereum_blocks_count = self.block_store.chain_head_block(&info.network)?;
58+
59+
Ok(info)
60+
}
5361
}
5462

5563
impl StoreTrait for Store {
@@ -117,29 +125,6 @@ impl StatusStore for Store {
117125
Ok(infos)
118126
}
119127

120-
fn version_info(&self, version_id: &str) -> Result<VersionInfo, StoreError> {
121-
let mut info = self.subgraph_store.version_info(version_id)?;
122-
123-
info.total_ethereum_blocks_count = self.block_store.chain_head_block(&info.network)?;
124-
125-
Ok(info)
126-
}
127-
128-
fn versions_for_subgraph_id(
129-
&self,
130-
subgraph_id: &str,
131-
) -> Result<(Option<String>, Option<String>), StoreError> {
132-
self.subgraph_store.versions_for_subgraph_id(subgraph_id)
133-
}
134-
135-
fn subgraphs_for_deployment_hash(
136-
&self,
137-
deployment_hash: &str,
138-
) -> Result<Vec<(String, String)>, StoreError> {
139-
self.subgraph_store
140-
.subgraphs_for_deployment_hash(deployment_hash)
141-
}
142-
143128
async fn get_proof_of_indexing(
144129
&self,
145130
subgraph_id: &DeploymentHash,

store/postgres/src/subgraph_store.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,20 +1017,6 @@ impl SubgraphStoreInner {
10171017
}
10181018
}
10191019

1020-
pub(crate) fn versions_for_subgraph_id(
1021-
&self,
1022-
subgraph_id: &str,
1023-
) -> Result<(Option<String>, Option<String>), StoreError> {
1024-
self.mirror.versions_for_subgraph_id(subgraph_id)
1025-
}
1026-
1027-
pub(crate) fn subgraphs_for_deployment_hash(
1028-
&self,
1029-
deployment_hash: &str,
1030-
) -> Result<Vec<(String, String)>, StoreError> {
1031-
self.mirror.subgraphs_by_deployment_hash(deployment_hash)
1032-
}
1033-
10341020
#[cfg(debug_assertions)]
10351021
pub fn error_count(&self, id: &DeploymentHash) -> Result<usize, StoreError> {
10361022
let (store, _) = self.store(id)?;

0 commit comments

Comments
 (0)