From 5b1ce146f9ce0266cbac0cfa8ee3d2822c56bc88 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 5 Nov 2023 13:38:35 +0100 Subject: [PATCH] is_syncing() for BlockChainTestClient + cargo fmt --all -- --config imports_granularity=Crate --- bin/oe/run.rs | 3 +-- crates/ethcore/src/client/client.rs | 7 +++++-- crates/ethcore/src/client/test_client.rs | 4 ++++ crates/ethcore/src/client/traits.rs | 1 - crates/rpc/src/v1/helpers/block_import.rs | 1 - 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/oe/run.rs b/bin/oe/run.rs index 76b0cff039..ff19042e22 100644 --- a/bin/oe/run.rs +++ b/bin/oe/run.rs @@ -164,11 +164,10 @@ impl ChainSyncing for SyncProviderWrapper { /// are we syncing in any means ? fn is_syncing(&self) -> bool { - match self.sync_provider.upgrade() { Some(sync_arc) => { return sync_arc.status().state != SyncState::Idle; - }, + } // We also indicate the "syncing" state when the SyncProvider has already been destroyed. None => true, } diff --git a/crates/ethcore/src/client/client.rs b/crates/ethcore/src/client/client.rs index 1024211d46..e6857c03ff 100644 --- a/crates/ethcore/src/client/client.rs +++ b/crates/ethcore/src/client/client.rs @@ -3663,8 +3663,11 @@ impl PrometheusMetrics for Client { ); // 0 or 1 if we are major syncing. - r.register_gauge("is_major_syncing", "syncing, boolean", self.is_major_syncing() as i64); - + r.register_gauge( + "is_major_syncing", + "syncing, boolean", + self.is_major_syncing() as i64, + ); r.register_gauge("is_syncing", "syncing, boolean", self.is_syncing() as i64); diff --git a/crates/ethcore/src/client/test_client.rs b/crates/ethcore/src/client/test_client.rs index 1cf8e308fe..df9a7dcd58 100644 --- a/crates/ethcore/src/client/test_client.rs +++ b/crates/ethcore/src/client/test_client.rs @@ -1114,6 +1114,10 @@ impl BlockChainClient for TestBlockChainClient { false } + fn is_syncing(&self) -> bool { + false + } + fn next_nonce(&self, address: &Address) -> U256 { self.miner.next_nonce(self, address) } diff --git a/crates/ethcore/src/client/traits.rs b/crates/ethcore/src/client/traits.rs index 26a42bc30b..63afe12299 100644 --- a/crates/ethcore/src/client/traits.rs +++ b/crates/ethcore/src/client/traits.rs @@ -215,7 +215,6 @@ pub trait EngineInfo { /// Provides information about the chain sync state. pub trait ChainSyncing: Send + Sync { - /// are we syncing? fn is_syncing(&self) -> bool; diff --git a/crates/rpc/src/v1/helpers/block_import.rs b/crates/rpc/src/v1/helpers/block_import.rs index 3d817f548a..b979334284 100644 --- a/crates/rpc/src/v1/helpers/block_import.rs +++ b/crates/rpc/src/v1/helpers/block_import.rs @@ -26,7 +26,6 @@ pub fn is_major_importing_or_waiting( queue_info: BlockQueueInfo, waiting_is_syncing_state: bool, ) -> bool { - let is_syncing_state = sync_state.map_or(false, |s| match s { SyncState::Idle | SyncState::NewBlocks => false, SyncState::WaitingPeers if !waiting_is_syncing_state => false,