Skip to content

Commit

Permalink
Fix peer header when no peers to show (#4411)
Browse files Browse the repository at this point in the history
* Fix peer header when no peers to show

* Only order once

* Better fix maybe

* Applying lukasz suggestion
  • Loading branch information
smartprogrammer93 authored and dceleda committed Sep 18, 2022
1 parent 42ebffb commit ee922d1
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/Nethermind/Nethermind.Synchronization/Peers/SyncPeersReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,15 @@ public void WriteFullReport()
}

RememberState(out bool _);
_stringBuilder.AppendLine($"Sync peers - Initialized: {_currentInitializedPeerCount} | All: {_peerPool.PeerCount} | Max: {_peerPool.PeerMaxCount}");
AddPeerHeader();
_stringBuilder.Append($"Sync peers - Initialized: {_currentInitializedPeerCount} | All: {_peerPool.PeerCount} | Max: {_peerPool.PeerMaxCount}");
bool headerAdded = false;
foreach (PeerInfo peerInfo in OrderedPeers)
{
if (!headerAdded)
{
headerAdded = true;
AddPeerHeader();
}
_stringBuilder.AppendLine();
AddPeerInfo(peerInfo);
}
Expand All @@ -83,17 +88,21 @@ public void WriteShortReport()
{
return;
}

RememberState(out bool changed);
if (!changed)
{
return;
}

_stringBuilder.AppendLine($"Sync peers {_currentInitializedPeerCount}({_peerPool.PeerCount})/{_peerPool.PeerMaxCount}");
AddPeerHeader();
_stringBuilder.Append($"Sync peers {_currentInitializedPeerCount}({_peerPool.PeerCount})/{_peerPool.PeerMaxCount}");
bool headerAdded = false;
foreach (PeerInfo peerInfo in OrderedPeers.Where(p => !p.CanBeAllocated(AllocationContexts.All)))
{
if (!headerAdded)
{
headerAdded = true;
AddPeerHeader();
}
_stringBuilder.AppendLine();
AddPeerInfo(peerInfo);
}
Expand All @@ -119,6 +128,7 @@ private void AddPeerInfo(PeerInfo peerInfo)

private void AddPeerHeader()
{
_stringBuilder.AppendLine();
_stringBuilder.Append("===")
.Append("[Active][Sleep ][Peer (ProtocolVersion/Head/Host:Port) ]")
.Append("[Transfer Speeds (L/H/B/R/N/S) ]")
Expand Down

0 comments on commit ee922d1

Please sign in to comment.