Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
sc-informant: Do not show Block history if doing major sync (#14094)
Browse files Browse the repository at this point in the history
After warp syncing a node it still downloads the block history. If the node is stopped and then
started later while downloading the block history, the node first needs to do a major sync to sync
to the tip of the chain. Before informant was showing `Block history` as sync state, while we
actually were doing a major sync. This pr is fixing this.
  • Loading branch information
bkchr authored May 8, 2023
1 parent 81d732b commit 33d94c2
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions client/informant/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,36 @@ impl<B: BlockT> InformantDisplay<B> {

let (level, status, target) =
match (sync_status.state, sync_status.state_sync, sync_status.warp_sync) {
// Do not set status to "Block history" when we are doing a major sync.
//
// A node could for example have been warp synced to the tip of the chain and
// shutdown. At the next start we still need to download the block history, but
// first will sync to the tip of the chain.
(
_,
sync_status,
_,
Some(WarpSyncProgress { phase: WarpSyncPhase::DownloadingBlocks(n), .. }),
) => ("⏩", "Block history".into(), format!(", #{}", n)),
) if !sync_status.is_major_syncing() => ("⏩", "Block history".into(), format!(", #{}", n)),
(
_,
_,
Some(WarpSyncProgress { phase: WarpSyncPhase::AwaitingTargetBlock, .. }),
) => ("⏩", "Waiting for pending target block".into(), "".into()),
(_, _, Some(warp)) => (
"⏩",
"Warping".into(),
format!(
", {}, {:.2} Mib",
// Handle all phases besides the two phases we already handle above.
(_, _, Some(warp))
if !matches!(
warp.phase,
(warp.total_bytes as f32) / (1024f32 * 1024f32)
WarpSyncPhase::AwaitingTargetBlock | WarpSyncPhase::DownloadingBlocks(_)
) =>
(
"⏩",
"Warping".into(),
format!(
", {}, {:.2} Mib",
warp.phase,
(warp.total_bytes as f32) / (1024f32 * 1024f32)
),
),
),
(_, Some(state), _) => (
"⚙️ ",
"Downloading state".into(),
Expand Down

0 comments on commit 33d94c2

Please sign in to comment.