Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Fetch program with resource requests if exists (#122)
Browse files Browse the repository at this point in the history
`Database.find_program(..)` is used e.g. in program manager, which
depends on embedded program resource requests, if such are configured.

Old version of this method didn't fetch them along the program data, so
the method is now a wrapper for `get_program(..)` but handles error as
non-existing program.
  • Loading branch information
tuommaki authored Mar 5, 2024
1 parent 4fb50c4 commit 03efb4b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/node/src/storage/database/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ impl Database {
}

pub async fn find_program(&self, hash: impl AsRef<Hash>) -> Result<Option<Program>> {
// non-macro query_as used because of sqlx limitations with enums.
let program = sqlx::query_as::<_, Program>("SELECT * FROM program WHERE hash = $1")
.bind(hash.as_ref())
.fetch_optional(&self.pool)
.await?;
let mut conn = self.pool.acquire().await?;
let program = match self.get_program(&mut conn, hash).await {
Ok(program) => Some(program),
Err(_) => None,
};

Ok(program)
}
Expand Down

0 comments on commit 03efb4b

Please sign in to comment.