diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Admin/PeerInfo.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Admin/PeerInfo.cs index b567abd394b..8bceb48f0e9 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Admin/PeerInfo.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Admin/PeerInfo.cs @@ -6,12 +6,14 @@ using System.Net; using Nethermind.Network; using Nethermind.Stats.Model; +using Nethermind.Core.Crypto; namespace Nethermind.JsonRpc.Modules.Admin { public class PeerInfo { - public string ClientId { get; set; } + public string Name { get; set; } + public string Id { get; } public string Host { get; set; } public int Port { get; set; } public string Address { get; set; } @@ -36,7 +38,8 @@ public PeerInfo(Peer peer, bool includeDetails) $"{nameof(PeerInfo)} cannot be created for a {nameof(Peer)} with an unknown {peer.Node}"); } - ClientId = peer.Node.ClientId; + Name = peer.Node.ClientId; + Id = CalculateClientId(peer.Node.Id); Host = peer.Node.Host is null ? null : IPAddress.Parse(peer.Node.Host).MapToIPv4().ToString(); Port = peer.Node.Port; Address = peer.Node.Address.ToString(); @@ -51,5 +54,11 @@ public PeerInfo(Peer peer, bool includeDetails) LastSignal = (peer.InSession ?? peer.OutSession)?.LastPingUtc.ToString(CultureInfo.InvariantCulture); } } + + private string CalculateClientId(PublicKey nodeKey) + { + byte[] publicKeyBytes = nodeKey.Bytes; + return (publicKeyBytes is null ? Keccak.Zero.ValueHash256 : ValueKeccak.Compute(publicKeyBytes)).ToString(false); + } } }