From 05e737537883a3c15f70d21a5ccfa0baffcdcea3 Mon Sep 17 00:00:00 2001 From: HaoqiangZhang Date: Wed, 3 Feb 2021 14:26:26 +0800 Subject: [PATCH] Show header height when show state (#737) * Add header height when show state Add header height when shou state * update PackageReference * Update MainService.Node.cs * Fix GUI Co-authored-by: Erik Zhang --- neo-cli/CLI/MainService.Node.cs | 5 ++++- neo-cli/neo-cli.csproj | 2 +- neo-gui/GUI/MainForm.cs | 6 ++++-- neo-gui/GUI/MainForm.resx | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/neo-cli/CLI/MainService.Node.cs b/neo-cli/CLI/MainService.Node.cs index a830f8eb7..0dd438c20 100644 --- a/neo-cli/CLI/MainService.Node.cs +++ b/neo-cli/CLI/MainService.Node.cs @@ -69,8 +69,11 @@ private void OnShowStateCommand() while (!cancel.Token.IsCancellationRequested) { + uint height = NativeContract.Ledger.CurrentIndex(Blockchain.Singleton.View); + uint headerHeight = Blockchain.Singleton.HeaderCache.Last?.Index ?? height; + Console.SetCursorPosition(0, 0); - WriteLineWithoutFlicker($"block: {NativeContract.Ledger.CurrentIndex(Blockchain.Singleton.View)} connected: {LocalNode.Singleton.ConnectedCount} unconnected: {LocalNode.Singleton.UnconnectedCount}", Console.WindowWidth - 1); + WriteLineWithoutFlicker($"block: {height}/{headerHeight} connected: {LocalNode.Singleton.ConnectedCount} unconnected: {LocalNode.Singleton.UnconnectedCount}", Console.WindowWidth - 1); int linesWritten = 1; foreach (RemoteNode node in LocalNode.Singleton.GetRemoteNodes().OrderByDescending(u => u.LastBlockIndex).Take(Console.WindowHeight - 2).ToArray()) diff --git a/neo-cli/neo-cli.csproj b/neo-cli/neo-cli.csproj index c04610e92..16a7572b0 100644 --- a/neo-cli/neo-cli.csproj +++ b/neo-cli/neo-cli.csproj @@ -28,7 +28,7 @@ - + diff --git a/neo-gui/GUI/MainForm.cs b/neo-gui/GUI/MainForm.cs index 738653fd9..38aa947a6 100644 --- a/neo-gui/GUI/MainForm.cs +++ b/neo-gui/GUI/MainForm.cs @@ -150,7 +150,7 @@ private void RefreshConfirmations() foreach (ListViewItem item in listView3.Items) { uint? height = item.Tag as uint?; - int? confirmations = (int)Blockchain.Singleton.Height - (int?)height + 1; + int? confirmations = (int)NativeContract.Ledger.CurrentIndex(Blockchain.Singleton.View) - (int?)height + 1; if (confirmations <= 0) confirmations = null; item.SubItems["confirmations"].Text = confirmations?.ToString() ?? Strings.Unconfirmed; } @@ -171,8 +171,10 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e) private void timer1_Tick(object sender, EventArgs e) { - lbl_height.Text = Blockchain.Singleton.Height.ToString(); + uint height = NativeContract.Ledger.CurrentIndex(Blockchain.Singleton.View); + uint headerHeight = Blockchain.Singleton.HeaderCache.Last?.Index ?? height; + lbl_height.Text = $"{height}/{headerHeight}"; lbl_count_node.Text = LocalNode.Singleton.ConnectedCount.ToString(); TimeSpan persistence_span = DateTime.UtcNow - persistence_time; if (persistence_span < TimeSpan.Zero) persistence_span = TimeSpan.Zero; diff --git a/neo-gui/GUI/MainForm.resx b/neo-gui/GUI/MainForm.resx index 3a532b89f..21c7f5a2b 100644 --- a/neo-gui/GUI/MainForm.resx +++ b/neo-gui/GUI/MainForm.resx @@ -521,7 +521,7 @@ 27, 17 - 0 + 0/0 73, 17