Skip to content
Merged
Changes from 2 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
20 changes: 13 additions & 7 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,20 +397,26 @@ impl DbClient {

/// One row per signer, preferring their build whose `executable_hash`
/// matches the on-chain hash (verified), else the most recent. Hash-less
/// builds are skipped.
/// builds are skipped. The returned rows are ordered with verified builds
/// first, then by signer for stable output.
pub async fn get_all_verification_info(
&self,
program_id: Address,
) -> Result<Vec<VerificationResponseWithSigner>> {
let state = self.get_program_state(&program_id).await?;
let on_chain_hash = state.as_ref().and_then(|s| s.on_chain_hash.clone());
let builds = sqlx::query_as::<_, BuildRow>(
"SELECT DISTINCT ON (signer) * FROM builds
WHERE program_id = $1 AND status = 'completed'
AND executable_hash IS NOT NULL
ORDER BY signer,
COALESCE(executable_hash = $2::text, false) DESC,
completed_at DESC NULLS LAST",
"WITH selected_builds AS (
SELECT DISTINCT ON (signer) * FROM builds
WHERE program_id = $1 AND status = 'completed'
AND executable_hash IS NOT NULL
ORDER BY signer,
COALESCE(executable_hash = $2::text, false) DESC,
completed_at DESC NULLS LAST
)
SELECT * FROM selected_builds
ORDER BY COALESCE(executable_hash = $2::text, false) DESC,
signer",
)
.bind(program_id)
.bind(&on_chain_hash)
Expand Down
Loading