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:
Nazar Mokrynskyi
2022-10-21 16:38:53 +03:00
committed by GitHub
parent 7f8aab84b1
commit bf57a2e92d
6 changed files with 71 additions and 62 deletions
+29 -34
View File
@@ -93,42 +93,37 @@ impl<B: BlockT> InformantDisplay<B> {
(diff_bytes_inbound, diff_bytes_outbound)
};
let (level, status, target) = match (
net_status.sync_state,
net_status.best_seen_block,
net_status.state_sync,
net_status.warp_sync,
) {
(
_,
_,
_,
Some(WarpSyncProgress { phase: WarpSyncPhase::DownloadingBlocks(n), .. }),
) => ("", "Block history".into(), format!(", #{}", n)),
(_, _, _, Some(warp)) => (
"",
"Warping".into(),
format!(
", {}, {:.2} Mib",
warp.phase,
(warp.total_bytes as f32) / (1024f32 * 1024f32)
let (level, status, target) =
match (net_status.sync_state, net_status.state_sync, net_status.warp_sync) {
(
_,
_,
Some(WarpSyncProgress { phase: WarpSyncPhase::DownloadingBlocks(n), .. }),
) => ("", "Block history".into(), format!(", #{}", n)),
(_, _, Some(warp)) => (
"",
"Warping".into(),
format!(
", {}, {:.2} Mib",
warp.phase,
(warp.total_bytes as f32) / (1024f32 * 1024f32)
),
),
),
(_, _, Some(state), _) => (
"⚙️ ",
"Downloading state".into(),
format!(
", {}%, {:.2} Mib",
state.percentage,
(state.size as f32) / (1024f32 * 1024f32)
(_, Some(state), _) => (
"⚙️ ",
"Downloading state".into(),
format!(
", {}%, {:.2} Mib",
state.percentage,
(state.size as f32) / (1024f32 * 1024f32)
),
),
),
(SyncState::Idle, _, _, _) => ("💤", "Idle".into(), "".into()),
(SyncState::Downloading, None, _, _) =>
("⚙️ ", format!("Preparing{}", speed), "".into()),
(SyncState::Downloading, Some(n), None, _) =>
("⚙️ ", format!("Syncing{}", speed), format!(", target=#{}", n)),
};
(SyncState::Idle, _, _) => ("💤", "Idle".into(), "".into()),
(SyncState::Downloading { target }, _, _) =>
("⚙️ ", format!("Syncing{}", speed), format!(", target=#{target}")),
(SyncState::Importing { target }, _, _) =>
("⚙️ ", format!("Preparing{}", speed), format!(", target=#{target}")),
};
if self.format.enable_color {
info!(