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

Show header height when show state #737

Merged
merged 4 commits into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion neo-cli/CLI/MainService.Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion neo-cli/neo-cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI01181" />
<PackageReference Include="Neo" Version="3.0.0-CI01184" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions neo-gui/GUI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion neo-gui/GUI/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@
<value>27, 17</value>
</data>
<data name="lbl_height.Text" xml:space="preserve">
<value>0</value>
<value>0/0</value>
</data>
<data name="toolStripStatusLabel4.Size" type="System.Drawing.Size, System.Drawing">
<value>73, 17</value>
Expand Down