Skip to content

Commit 54c667f

Browse files
dimitrovmaksimincrypto32
authored andcommitted
fix(node, store): Use DeploymentId for rewind and truncate (#6299)
Signed-off-by: Maksim Dimitrov <dimitrov.maksim@gmail.com>
1 parent 872e708 commit 54c667f

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

node/src/manager/commands/rewind.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ pub async fn run(
171171

172172
match (block_ptr_to, start_block) {
173173
(Some(block_ptr), _) => {
174-
subgraph_store.rewind(loc.hash.clone(), block_ptr)?;
174+
subgraph_store.rewind(loc.id, block_ptr)?;
175175
println!(" ... rewound {}", loc);
176176
}
177177
(None, Some(start_block_ptr)) => {
178-
subgraph_store.truncate(loc.hash.clone(), start_block_ptr)?;
178+
subgraph_store.truncate(loc.id, start_block_ptr)?;
179179
println!(" ... truncated {}", loc);
180180
}
181181
(None, None) => {

store/postgres/src/subgraph_store.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ use graph::{
2121
PruneReporter, PruneRequest, SubgraphFork,
2222
},
2323
},
24-
data::query::QueryTarget,
25-
data::subgraph::{schema::DeploymentCreate, status, DeploymentFeatures},
24+
data::{
25+
query::QueryTarget,
26+
subgraph::{schema::DeploymentCreate, status, DeploymentFeatures},
27+
},
2628
internal_error,
2729
prelude::{
2830
anyhow, lazy_static, o, web3::types::Address, ApiVersion, BlockNumber, BlockPtr,
@@ -1043,13 +1045,15 @@ impl SubgraphStoreInner {
10431045
join_all(self.stores.values().map(|store| store.vacuum())).await
10441046
}
10451047

1046-
pub fn rewind(&self, id: DeploymentHash, block_ptr_to: BlockPtr) -> Result<(), StoreError> {
1047-
let (store, site) = self.store(&id)?;
1048+
pub fn rewind(&self, id: DeploymentId, block_ptr_to: BlockPtr) -> Result<(), StoreError> {
1049+
let site = self.find_site(id)?;
1050+
let store = self.for_site(&site)?;
10481051
store.rewind(site, block_ptr_to)
10491052
}
10501053

1051-
pub fn truncate(&self, id: DeploymentHash, block_ptr_to: BlockPtr) -> Result<(), StoreError> {
1052-
let (store, site) = self.store(&id)?;
1054+
pub fn truncate(&self, id: DeploymentId, block_ptr_to: BlockPtr) -> Result<(), StoreError> {
1055+
let site = self.find_site(id)?;
1056+
let store = self.for_site(&site)?;
10531057
store.truncate(site, block_ptr_to)
10541058
}
10551059

tests/src/fixture/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ impl TestContext {
363363

364364
pub fn rewind(&self, block_ptr_to: BlockPtr) {
365365
self.store
366-
.rewind(self.deployment.hash.clone(), block_ptr_to)
366+
.rewind(self.deployment.id, block_ptr_to)
367367
.unwrap()
368368
}
369369
}

0 commit comments

Comments
 (0)