Skip to content

Commit

Permalink
Update sql
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest committed May 8, 2024
1 parent a70e301 commit 869a1dd
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions client/db/src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,17 +866,11 @@ impl<Block: BlockT<Hash = H256>> fc_api::Backend<Block> for Backend<Block> {

async fn best_hash(&self) -> Result<Block::Hash, String> {
// Retrieves the block hash for the latest indexed block, maybe it's not canon.
sqlx::query(
"SELECT b.substrate_block_hash FROM blocks AS b
INNER JOIN sync_status AS s
ON s.substrate_block_hash = b.substrate_block_hash
WHERE s.status = 1
ORDER BY b.block_number DESC LIMIT 1",
)
.fetch_one(self.pool())
.await
.map(|row| H256::from_slice(&row.get::<Vec<u8>, _>(0)[..]))
.map_err(|e| format!("Failed to fetch best hash: {}", e))
sqlx::query("SELECT substrate_block_hash FROM blocks ORDER BY block_number DESC LIMIT 1")
.fetch_one(self.pool())
.await
.map(|row| H256::from_slice(&row.get::<Vec<u8>, _>(0)[..]))
.map_err(|e| format!("Failed to fetch best hash: {}", e))
}
}

Expand Down

0 comments on commit 869a1dd

Please sign in to comment.