mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 05:17:58 +00:00
Actually fix major sync detection (#12114)
* Actually fix major sync detection * Introduce `SyncState::Importing` state * Add target to SyncState enum variants and add `is_major_syncing` method on it * Remove unnecessary duplicated `best_seen_block` from `SyncState` struct * Revert "Remove unnecessary duplicated `best_seen_block` from `SyncState` struct" This reverts commit bb8abd458c939881c049f69d59f3acba47c97c5c. * Add missing `websocket` feature to `libp2p` Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -98,7 +98,7 @@ where
|
||||
#[derive(Clone)]
|
||||
pub struct NetworkStatus<B: BlockT> {
|
||||
/// Current global sync state.
|
||||
pub sync_state: SyncState,
|
||||
pub sync_state: SyncState<NumberFor<B>>,
|
||||
/// Target sync block number.
|
||||
pub best_seen_block: Option<NumberFor<B>>,
|
||||
/// Number of peers participating in syncing.
|
||||
|
||||
@@ -44,11 +44,20 @@ pub struct PeerInfo<Block: BlockT> {
|
||||
|
||||
/// Reported sync state.
|
||||
#[derive(Clone, Eq, PartialEq, Debug)]
|
||||
pub enum SyncState {
|
||||
pub enum SyncState<BlockNumber> {
|
||||
/// Initial sync is complete, keep-up sync is active.
|
||||
Idle,
|
||||
/// Actively catching up with the chain.
|
||||
Downloading,
|
||||
Downloading { target: BlockNumber },
|
||||
/// All blocks are downloaded and are being imported.
|
||||
Importing { target: BlockNumber },
|
||||
}
|
||||
|
||||
impl<BlockNumber> SyncState<BlockNumber> {
|
||||
/// Are we actively catching up with the chain?
|
||||
pub fn is_major_syncing(&self) -> bool {
|
||||
!matches!(self, SyncState::Idle)
|
||||
}
|
||||
}
|
||||
|
||||
/// Reported state download progress.
|
||||
@@ -64,7 +73,7 @@ pub struct StateDownloadProgress {
|
||||
#[derive(Clone)]
|
||||
pub struct SyncStatus<Block: BlockT> {
|
||||
/// Current global sync state.
|
||||
pub state: SyncState,
|
||||
pub state: SyncState<NumberFor<Block>>,
|
||||
/// Target sync block number.
|
||||
pub best_seen_block: Option<NumberFor<Block>>,
|
||||
/// Number of peers participating in syncing.
|
||||
|
||||
Reference in New Issue
Block a user