From 75f776005e99bb0794abe93b314b8a715151174b Mon Sep 17 00:00:00 2001 From: Denis Avvakumov Date: Thu, 14 Sep 2023 14:53:08 +0300 Subject: [PATCH] NDEV-2183: Make EthSyncing fields public --- evm_loader/lib/src/types/tracer_ch_common.rs | 6 +++--- evm_loader/lib/src/types/tracer_ch_db.rs | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/evm_loader/lib/src/types/tracer_ch_common.rs b/evm_loader/lib/src/types/tracer_ch_common.rs index 2aa0c64284..c7c0e54f43 100644 --- a/evm_loader/lib/src/types/tracer_ch_common.rs +++ b/evm_loader/lib/src/types/tracer_ch_common.rs @@ -125,7 +125,7 @@ impl EthSyncStatus { #[derive(Row, Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct EthSyncing { - starting_block: u64, - current_block: u64, - highest_block: u64, + pub starting_block: u64, + pub current_block: u64, + pub highest_block: u64, } diff --git a/evm_loader/lib/src/types/tracer_ch_db.rs b/evm_loader/lib/src/types/tracer_ch_db.rs index 05b9197c72..bd44d29b48 100644 --- a/evm_loader/lib/src/types/tracer_ch_db.rs +++ b/evm_loader/lib/src/types/tracer_ch_db.rs @@ -506,7 +506,7 @@ impl ClickHouseDb { } } - pub async fn get_slot_by_blockhash(&self, blockhash: &str) -> ChResult> { + pub async fn get_slot_by_blockhash(&self, blockhash: &str) -> ChResult { let query = r#"SELECT slot FROM events.notify_block_distributed WHERE hash = ? @@ -521,7 +521,15 @@ impl ClickHouseDb { .await, )?; - Ok(slot) + match slot { + Some(slot) => return Ok(slot), + None => { + let err = clickhouse::error::Error::Custom(format!( + "get_sync_status: no data available", + )); + return Err(ChError::Db(err)); + } + } } pub async fn get_sync_status(&self) -> ChResult {