Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fix base node console display #6341

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ impl StateInfo {
.unwrap_or_else(|| "".to_string())
),
HeaderSync(None) => "Starting header sync".to_string(),
HeaderSync(Some(info)) => format!("Syncing headers: {}", info.sync_progress_string()),
HeaderSync(Some(info)) => format!("Syncing headers: {}", info.sync_progress_string_headers()),
HorizonSync(info) => info.to_progress_string(),

BlockSync(info) => format!("Syncing blocks: {}", info.sync_progress_string()),
BlockSync(info) => format!("Syncing blocks: {}", info.sync_progress_string_blocks()),
Listening(_) => "Listening".to_string(),
SyncFailed(details) => format!("Sync failed: {}", details),
}
Expand Down Expand Up @@ -299,7 +299,15 @@ impl BlockSyncInfo {
}
}

pub fn sync_progress_string(&self) -> String {
pub fn sync_progress_string_headers(&self) -> String {
self.sync_progress("hdrs")
}

pub fn sync_progress_string_blocks(&self) -> String {
self.sync_progress("blks")
}

fn sync_progress(&self, item: &str) -> String {
format!(
"({}) {}/{} ({:.0}%){}{}",
self.sync_peer.node_id().short_str(),
Expand All @@ -308,7 +316,7 @@ impl BlockSyncInfo {
(self.local_height as f64 / self.tip_height as f64 * 100.0).floor(),
self.sync_peer
.items_per_second()
.map(|bps| format!(" {:.2?} blks/s", bps))
.map(|bps| format!(" {:.2?} {}/s", bps, item))
.unwrap_or_default(),
self.sync_peer
.calc_avg_latency()
Expand All @@ -320,6 +328,6 @@ impl BlockSyncInfo {

impl Display for BlockSyncInfo {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
writeln!(f, "Syncing {}", self.sync_progress_string())
writeln!(f, "Syncing {}", self.sync_progress_string_blocks())
}
}
Loading