Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions node/src/manager/commands/rewind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ pub async fn run(

match (block_ptr_to, start_block) {
(Some(block_ptr), _) => {
subgraph_store.rewind(loc.hash.clone(), block_ptr).await?;
subgraph_store.rewind(loc.id.into(), block_ptr).await?;
println!(" ... rewound {}", loc);
}
(None, Some(start_block_ptr)) => {
subgraph_store
.truncate(loc.hash.clone(), start_block_ptr)
.truncate(loc.id.into(), start_block_ptr)
.await?;
println!(" ... truncated {}", loc);
}
Expand Down
23 changes: 11 additions & 12 deletions store/postgres/src/subgraph_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ use graph::{
PruneReporter, PruneRequest, SubgraphFork,
},
},
data::query::QueryTarget,
data::subgraph::{schema::DeploymentCreate, status, DeploymentFeatures},
data::{
query::QueryTarget,
subgraph::{schema::DeploymentCreate, status, DeploymentFeatures},
},
internal_error,
prelude::StoreEvent,
prelude::{
anyhow, lazy_static, o, ApiVersion, BlockNumber, BlockPtr, ChainStore, DeploymentHash,
EntityOperation, Logger, MetricsRegistry, NodeId, PartialBlockPtr, StoreError,
EntityOperation, Logger, MetricsRegistry, NodeId, PartialBlockPtr, StoreError, StoreEvent,
SubgraphDeploymentEntity, SubgraphName, SubgraphStore as SubgraphStoreTrait,
SubgraphVersionSwitchingMode,
},
Expand Down Expand Up @@ -1091,21 +1092,19 @@ impl Inner {
join_all(self.stores.values().map(|store| store.vacuum())).await
}

pub async fn rewind(
&self,
id: DeploymentHash,
block_ptr_to: BlockPtr,
) -> Result<(), StoreError> {
let (store, site) = self.store(&id).await?;
pub async fn rewind(&self, id: DeploymentId, block_ptr_to: BlockPtr) -> Result<(), StoreError> {
let site = self.find_site(id).await?;
let store = self.for_site(&site)?;
store.rewind(site, block_ptr_to).await
}

pub async fn truncate(
&self,
id: DeploymentHash,
id: DeploymentId,
block_ptr_to: BlockPtr,
) -> Result<(), StoreError> {
let (store, site) = self.store(&id).await?;
let site = self.find_site(id).await?;
let store = self.for_site(&site)?;
store.truncate(site, block_ptr_to).await
}

Expand Down
2 changes: 1 addition & 1 deletion tests/src/fixture/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ impl TestContext {

pub async fn rewind(&self, block_ptr_to: BlockPtr) {
self.store
.rewind(self.deployment.hash.clone(), block_ptr_to)
.rewind(self.deployment.id.into(), block_ptr_to)
.await
.unwrap()
}
Expand Down