Skip to content

Commit bb8abd4

Browse files
committed
Remove unnecessary duplicated best_seen_block from SyncState struct
1 parent 03df7d5 commit bb8abd4

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

client/network/common/src/sync.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ pub struct StateDownloadProgress {
7474
pub struct SyncStatus<Block: BlockT> {
7575
/// Current global sync state.
7676
pub state: SyncState<NumberFor<Block>>,
77-
/// Target sync block number.
78-
pub best_seen_block: Option<NumberFor<Block>>,
7977
/// Number of peers participating in syncing.
8078
pub num_peers: u32,
8179
/// Number of blocks queued for import

client/network/src/protocol.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use sc_network_common::{
5252
warp::{EncodedProof, WarpProofRequest},
5353
BadPeer, ChainSync, OnBlockData, OnBlockJustification, OnStateData, OpaqueBlockRequest,
5454
OpaqueBlockResponse, OpaqueStateRequest, OpaqueStateResponse, PollBlockAnnounceValidation,
55-
SyncStatus,
55+
SyncState, SyncStatus,
5656
},
5757
};
5858
use sp_arithmetic::traits::SaturatedConversion;
@@ -501,7 +501,11 @@ where
501501

502502
/// Target sync block number.
503503
pub fn best_seen_block(&self) -> Option<NumberFor<B>> {
504-
self.chain_sync.status().best_seen_block
504+
match self.chain_sync.status().state {
505+
SyncState::Idle => None,
506+
SyncState::Downloading { target } => Some(target),
507+
SyncState::Importing { .. } => None,
508+
}
505509
}
506510

507511
/// Number of peers participating in syncing.

client/network/sync/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,6 @@ where
390390
/// Returns the current sync status.
391391
fn status(&self) -> SyncStatus<B> {
392392
let median_seen = self.median_seen();
393-
let best_seen_block =
394-
median_seen.and_then(|median| (median > self.best_queued_number).then_some(median));
395393
let sync_state = if let Some(target) = median_seen {
396394
// A chain is classified as downloading if the provided best block is
397395
// more than `MAJOR_SYNC_BLOCKS` behind the best block or as importing
@@ -424,7 +422,6 @@ where
424422

425423
SyncStatus {
426424
state: sync_state,
427-
best_seen_block,
428425
num_peers: self.peers.len() as u32,
429426
queued_blocks: self.queue_blocks.len() as u32,
430427
state_sync: self.state_sync.as_ref().map(|s| s.progress()),

0 commit comments

Comments
 (0)