Skip to content

Commit

Permalink
is_syncing() for BlockChainTestClient +
Browse files Browse the repository at this point in the history
 cargo fmt --all -- --config imports_granularity=Crate
  • Loading branch information
SurfingNerd committed Nov 5, 2023
1 parent 061e160 commit 5b1ce14
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
3 changes: 1 addition & 2 deletions bin/oe/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
7 changes: 5 additions & 2 deletions crates/ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 4 additions & 0 deletions crates/ethcore/src/client/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 0 additions & 1 deletion crates/ethcore/src/client/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion crates/rpc/src/v1/helpers/block_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5b1ce14

Please sign in to comment.