From 7f4c2289bdf8f10c0589d112ba792086e40346e8 Mon Sep 17 00:00:00 2001 From: zhengpeng <847850277@qq.com> Date: Thu, 28 Nov 2024 11:15:58 +0800 Subject: [PATCH] [ISSUES#]2721 health_check_provider. --- crates/torii/core/src/engine.rs | 3 ++- crates/torii/core/src/utils.rs | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/crates/torii/core/src/engine.rs b/crates/torii/core/src/engine.rs index 86730665f3..5285d71f45 100644 --- a/crates/torii/core/src/engine.rs +++ b/crates/torii/core/src/engine.rs @@ -45,6 +45,7 @@ use crate::processors::{ }; use crate::sql::{Cursors, Sql}; use crate::types::{Contract, ContractType}; +use crate::utils::health_check_provider; type EventProcessorMap
= HashMap {
}
pub async fn start(&mut self) -> Result<()> {
+ health_check_provider(self.provider.clone()).await;
let mut backoff_delay = Duration::from_secs(1);
let max_backoff_delay = Duration::from_secs(60);
@@ -300,7 +302,6 @@ impl {
// TODO: since we now process blocks in chunks we can parallelize the fetching of data
pub async fn fetch_data(&mut self, cursors: &Cursors) -> Result ,
+) {
+ let latest_block = provider.get_block_with_tx_hashes(BlockId::Tag(BlockTag::Latest)).await;
+ if let Ok(latest_block) = latest_block {
+ info!("Provider health_check latest_block is: {:?}", latest_block);
+ } else {
+ error!("Provider: {:?} is unhealthy. please check you config!", provider);
+ }
+}
+
// tests
#[cfg(test)]
mod tests {