diff --git a/client/api/src/backend.rs b/client/api/src/backend.rs index 8a25a053de..8a0406883e 100644 --- a/client/api/src/backend.rs +++ b/client/api/src/backend.rs @@ -53,8 +53,8 @@ pub trait Backend: Send + Sync { self.log_indexer().is_indexed() } - /// Get the latest substrate block hash in the sql database. - async fn best_hash(&self) -> Result; + /// Get the hash of the latest substrate block fully indexed by the backend. + async fn latest_block_hash(&self) -> Result; } #[derive(Debug, Eq, PartialEq)] diff --git a/client/db/src/kv/mod.rs b/client/db/src/kv/mod.rs index bacf0025f5..73470f4aea 100644 --- a/client/db/src/kv/mod.rs +++ b/client/db/src/kv/mod.rs @@ -90,7 +90,7 @@ impl> fc_api::Backend for Backend< &self.log_indexer } - async fn best_hash(&self) -> Result { + async fn latest_block_hash(&self) -> Result { Ok(self.client.info().best_hash) } } diff --git a/client/db/src/sql/mod.rs b/client/db/src/sql/mod.rs index ce7a56000e..0675e4a9e9 100644 --- a/client/db/src/sql/mod.rs +++ b/client/db/src/sql/mod.rs @@ -866,8 +866,8 @@ impl> fc_api::Backend for Backend { self } - async fn best_hash(&self) -> Result { - // Retrieves the block hash for the latest indexed block, maybe it's not canon. + async fn latest_block_hash(&self) -> Result { + // Retrieves the block hash for the latestindexed block, maybe it's not canon. sqlx::query("SELECT substrate_block_hash FROM blocks ORDER BY block_number DESC LIMIT 1") .fetch_one(self.pool()) .await diff --git a/client/rpc/src/lib.rs b/client/rpc/src/lib.rs index dc138191c6..2d8513b307 100644 --- a/client/rpc/src/lib.rs +++ b/client/rpc/src/lib.rs @@ -210,10 +210,10 @@ pub mod frontier_backend_client { BlockNumberOrHash::Num(number) => { Ok(Some(BlockId::Number(number.unique_saturated_into()))) } - BlockNumberOrHash::Latest => match backend.best_hash().await { + BlockNumberOrHash::Latest => match backend.latest_block_hash().await { Ok(hash) => Ok(Some(BlockId::Hash(hash))), Err(e) => { - log::warn!(target: "rpc", "Failed to get best hash from the sql db: {:?}", e); + log::warn!(target: "rpc", "Failed to get latest block hash from the sql db: {:?}", e); Ok(Some(BlockId::Hash(client.info().best_hash))) } },