Skip to content
Closed
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
18 changes: 9 additions & 9 deletions node/src/manager/commands/rewind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use graph::anyhow::bail;
use graph::components::store::{BlockStore as _, ChainStore as _, DeploymentLocator};
use graph::env::ENV_VARS;
use graph::prelude::{anyhow, BlockNumber, BlockPtr};
use graph_store_postgres::command_support::catalog::{self as store_catalog};
use graph_store_postgres::{connection_pool::ConnectionPool, Store};
use graph_store_postgres::{BlockStore, NotificationSender};

Expand Down Expand Up @@ -78,8 +77,6 @@ pub async fn run(
if !start_block && (block_hash.is_none() || block_number.is_none()) {
bail!("--block-hash and --block-number must be specified when --start-block is not set");
}
let pconn = primary.get()?;
let mut conn = store_catalog::Connection::new(pconn);

let subgraph_store = store.subgraph_store();
let block_store = store.block_store();
Expand Down Expand Up @@ -126,12 +123,15 @@ pub async fn run(

println!("Checking if its safe to rewind deployments");
for (_, locator) in &locators {
let site = conn
.locate_site(locator.clone())?
.ok_or_else(|| anyhow!("failed to locate site for {locator}"))?;
let deployment_store = subgraph_store.for_site(&site)?;
let deployment_details = deployment_store.deployment_details_for_id(locator)?;
let block_number_to = block_ptr_to.as_ref().map(|b| b.number).unwrap_or(0);
let deployment_details = subgraph_store.load_deployment_by_id(locator.clone().into())?;
let mut block_number_to = block_ptr_to.as_ref().map(|b| b.number).unwrap_or(0);

if start_block {
block_number_to = match deployment_details.start_block {
Some(block) => block.number,
None => 0,
};
}

if block_number_to < deployment_details.earliest_block_number + ENV_VARS.reorg_threshold {
bail!(
Expand Down
Loading