From 9acda28c166d11d8ca5c1f7d47e0c66c3b368b56 Mon Sep 17 00:00:00 2001
From: Robert Habermeier <rphmeier@gmail.com>
Date: Thu, 10 Jan 2019 14:19:31 -0300
Subject: [PATCH] informant: display finalized height and hash (#1387)

---
 substrate/core/cli/src/informant.rs | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/substrate/core/cli/src/informant.rs b/substrate/core/cli/src/informant.rs
index e9dab4ae8be..0f24f5f6e69 100644
--- a/substrate/core/cli/src/informant.rs
+++ b/substrate/core/cli/src/informant.rs
@@ -48,10 +48,10 @@ pub fn start<C>(service: &Service<C>, exit: ::exit_future::Exit, handle: TaskExe
 	let display_notifications = interval.map_err(|e| debug!("Timer error: {:?}", e)).for_each(move |_| {
 		let sync_status = network.status();
 
-		if let Ok(best_block) = client.best_block_header() {
-			let hash = best_block.hash();
+		if let Ok(info) = client.info() {
+			let best_number: u64 = info.chain.best_number.as_();
+			let best_hash = info.chain.best_hash;
 			let num_peers = sync_status.num_peers;
-			let best_number: u64 = best_block.number().as_();
 			let speed = move || speed(best_number, last_number);
 			let (status, target) = match (sync_status.sync.state, sync_status.sync.best_seen_block) {
 				(SyncState::Idle, _) => ("Idle".into(), "".into()),
@@ -60,14 +60,17 @@ pub fn start<C>(service: &Service<C>, exit: ::exit_future::Exit, handle: TaskExe
 			};
 			last_number = Some(best_number);
 			let txpool_status = txpool.status();
+			let finalized_number: u64 = info.chain.finalized_number.as_();
 			info!(
 				target: "substrate",
-				"{}{} ({} peers), best: #{} ({})",
+				"{}{} ({} peers), best: #{} ({}), finalized #{} ({})",
 				Colour::White.bold().paint(&status),
 				target,
 				Colour::White.bold().paint(format!("{}", sync_status.num_peers)),
 				Colour::White.paint(format!("{}", best_number)),
-				hash
+				best_hash,
+				Colour::White.paint(format!("{}", finalized_number)),
+				info.chain.finalized_hash,
 			);
 
 			// get cpu usage and memory usage of this process
@@ -81,10 +84,12 @@ pub fn start<C>(service: &Service<C>, exit: ::exit_future::Exit, handle: TaskExe
 				"status" => format!("{}{}", status, target),
 				"peers" => num_peers,
 				"height" => best_number,
-				"best" => ?hash,
+				"best" => ?best_hash,
 				"txcount" => txpool_status.ready,
 				"cpu" => cpu_usage,
-				"memory" => memory
+				"memory" => memory,
+				"finalized_height" => finalized_number,
+				"finalized_hash" => ?info.chain.finalized_hash,
 			);
 		} else {
 			warn!("Error getting best block information");
-- 
GitLab