Skip to content

Commit

Permalink
core: use existence check in graft_pending
Browse files Browse the repository at this point in the history
  • Loading branch information
incrypto32 committed Jun 21, 2023
1 parent 5062fe8 commit f275665
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions core/src/subgraph/registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,16 @@ async fn create_subgraph_version<C: Blockchain, S: SubgraphStore>(
)
.map_err(SubgraphRegistrarError::ResolveError)
.await?;
let exists = store.is_deployed(&deployment)?;
let should_validate = !exists || store.graft_pending(&deployment)?;

// Determine if the graft_base should be validated.
// Validate the graft_base if there is a pending graft, ensuring its presence.
// If the subgraph is new (indicated by DeploymentNotFound), the graft_base should be validated.
// If the subgraph already exists and there is no pending graft, graft_base validation is not required.
let should_validate = match store.graft_pending(&deployment) {
Ok(graft_pending) => graft_pending,
Err(StoreError::DeploymentNotFound(_)) => true,
Err(e) => return Err(SubgraphRegistrarError::StoreError(e)),
};
let manifest = unvalidated
.validate(store.cheap_clone(), should_validate)
.await
Expand Down
4 changes: 2 additions & 2 deletions store/postgres/src/primary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1247,9 +1247,9 @@ impl<'a> Connection<'a> {
}

/// Create a site for a brand new deployment.
/// If it already exists, return the existing site.
/// If it already exists, return the existing site
/// and a boolean indicating whether a new site was created.
/// false means the site already existed.
/// `false` means the site already existed.
pub fn allocate_site(
&self,
shard: Shard,
Expand Down

0 comments on commit f275665

Please sign in to comment.