From 4a2269ce395e56693436bec3f4ef2c95d609190f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Mon, 22 May 2023 22:23:10 +0200 Subject: [PATCH] WarpSync: Show number of required peers in informant (#14190) This makes it for the user more obvious on what we are waiting and not just "waiting for peers". --- client/network/common/src/sync/warp.rs | 5 +++-- client/network/sync/src/lib.rs | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/client/network/common/src/sync/warp.rs b/client/network/common/src/sync/warp.rs index aef257af4d057..37a6e62c53b4e 100644 --- a/client/network/common/src/sync/warp.rs +++ b/client/network/common/src/sync/warp.rs @@ -72,7 +72,7 @@ pub trait WarpSyncProvider: Send + Sync { #[derive(Clone, Eq, PartialEq, Debug)] pub enum WarpSyncPhase { /// Waiting for peers to connect. - AwaitingPeers, + AwaitingPeers { required_peers: usize }, /// Waiting for target block to be received. AwaitingTargetBlock, /// Downloading and verifying grandpa warp proofs. @@ -90,7 +90,8 @@ pub enum WarpSyncPhase { impl fmt::Display for WarpSyncPhase { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - Self::AwaitingPeers => write!(f, "Waiting for peers"), + Self::AwaitingPeers { required_peers } => + write!(f, "Waiting for {required_peers} peers to be connected"), Self::AwaitingTargetBlock => write!(f, "Waiting for target block to be received"), Self::DownloadingWarpProofs => write!(f, "Downloading finality proofs"), Self::DownloadingTargetBlock => write!(f, "Downloading target block"), diff --git a/client/network/sync/src/lib.rs b/client/network/sync/src/lib.rs index 3f1cbebd57255..fbdb275a444cd 100644 --- a/client/network/sync/src/lib.rs +++ b/client/network/sync/src/lib.rs @@ -515,8 +515,12 @@ where phase: WarpSyncPhase::DownloadingBlocks(gap_sync.best_queued_number), total_bytes: 0, }), - (None, SyncMode::Warp, _) => - Some(WarpSyncProgress { phase: WarpSyncPhase::AwaitingPeers, total_bytes: 0 }), + (None, SyncMode::Warp, _) => Some(WarpSyncProgress { + phase: WarpSyncPhase::AwaitingPeers { + required_peers: MIN_PEERS_TO_START_WARP_SYNC, + }, + total_bytes: 0, + }), (Some(sync), _, _) => Some(sync.progress()), _ => None, };