From 869a1dd8e5d9f540d8ee5039656e25db795ef566 Mon Sep 17 00:00:00 2001 From: bear Date: Wed, 8 May 2024 16:30:34 +0800 Subject: [PATCH] Update sql --- client/db/src/sql/mod.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/client/db/src/sql/mod.rs b/client/db/src/sql/mod.rs index f5494ad92e..bbff4e402a 100644 --- a/client/db/src/sql/mod.rs +++ b/client/db/src/sql/mod.rs @@ -866,17 +866,11 @@ impl> fc_api::Backend for Backend { async fn best_hash(&self) -> Result { // 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::, _>(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::, _>(0)[..])) + .map_err(|e| format!("Failed to fetch best hash: {}", e)) } }