diff --git a/src/console/LibplanetConsole.Console.Executable/EntryCommands/PortGenerationMode.cs b/src/common/LibplanetConsole.Common/PortGenerationMode.cs similarity index 51% rename from src/console/LibplanetConsole.Console.Executable/EntryCommands/PortGenerationMode.cs rename to src/common/LibplanetConsole.Common/PortGenerationMode.cs index 1a7dcf8a..60ec74bb 100644 --- a/src/console/LibplanetConsole.Console.Executable/EntryCommands/PortGenerationMode.cs +++ b/src/common/LibplanetConsole.Common/PortGenerationMode.cs @@ -1,4 +1,4 @@ -namespace LibplanetConsole.Console.Executable.EntryCommands; +namespace LibplanetConsole.Common; public enum PortGenerationMode { diff --git a/src/common/LibplanetConsole.Common/PortGenerator.cs b/src/common/LibplanetConsole.Common/PortGenerator.cs new file mode 100644 index 00000000..f40006c9 --- /dev/null +++ b/src/common/LibplanetConsole.Common/PortGenerator.cs @@ -0,0 +1,60 @@ +using System.Net.Sockets; +using LibplanetConsole.Common.DataAnnotations; + +namespace LibplanetConsole.Common; + +public sealed class PortGenerator +{ + public const int DefaultSpace = 10; + private readonly List _portList = []; + + public PortGenerator(int startingPort) + { + _portList.Add(startingPort == 0 ? PortUtility.NextPort() : startingPort); + Current = _portList[0]; + } + + public int Space { get; init; } = DefaultSpace; + + public int Current { get; private set; } + + public PortGenerationMode Mode { get; init; } = PortGenerationMode.Random; + + public int Next() + { + Current = GetPort(Current); + _portList.Add(Current); + _portList.Sort(); + return Current; + } + + private int GetPort(int nextPort) + { + if (Mode == PortGenerationMode.Random) + { + var port = PortUtility.NextPort(); + while (IsValidRandomPort(port) is false) + { + port = PortUtility.NextPort(); + } + + return port; + } + + return nextPort + Space; + } + + private bool IsValidRandomPort(int randomPort) + { + for (var i = 0; i < _portList.Count; i++) + { + var port = _portList[i]; + if (Math.Abs(port - randomPort) < Space) + { + return false; + } + } + + return true; + } +} diff --git a/src/console/LibplanetConsole.Console.Executable/ApplicationSettings.cs b/src/console/LibplanetConsole.Console.Executable/ApplicationSettings.cs index 4964a35e..7057f04c 100644 --- a/src/console/LibplanetConsole.Console.Executable/ApplicationSettings.cs +++ b/src/console/LibplanetConsole.Console.Executable/ApplicationSettings.cs @@ -91,10 +91,11 @@ internal sealed record class ApplicationSettings public ApplicationOptions ToOptions() { - var port = Port == 0 ? PortUtility.NextPort() : Port; + var portGenerator = new PortGenerator(Port); + var port = portGenerator.Current; var endPoint = GetLocalHost(port); - var nodeOptions = GetNodeOptions(endPoint, GetNodes()); - var clientOptions = GetClientOptions(nodeOptions, GetClients()); + var nodeOptions = GetNodeOptions(endPoint, GetNodes(), portGenerator); + var clientOptions = GetClientOptions(nodeOptions, GetClients(), portGenerator); var repository = new Repository(port, nodeOptions, clientOptions); var genesis = TryGetGenesis(out var g) == true ? g : repository.Genesis; return new ApplicationOptions(port) @@ -130,22 +131,22 @@ public static ApplicationSettings Parse(string[] args) } private static NodeOptions[] GetNodeOptions( - EndPoint endPoint, PrivateKey[] nodePrivateKeys) + EndPoint endPoint, PrivateKey[] nodePrivateKeys, PortGenerator portGenerator) { return [.. nodePrivateKeys.Select(key => new NodeOptions { - EndPoint = NextEndPoint(), + EndPoint = GetLocalHost(portGenerator.Next()), PrivateKey = key, SeedEndPoint = endPoint, })]; } private static ClientOptions[] GetClientOptions( - NodeOptions[] nodeOptions, PrivateKey[] clientPrivateKeys) + NodeOptions[] nodeOptions, PrivateKey[] clientPrivateKeys, PortGenerator portGenerator) { return [.. clientPrivateKeys.Select(key => new ClientOptions { - EndPoint = NextEndPoint(), + EndPoint = GetLocalHost(portGenerator.Next()), NodeEndPoint = Random(nodeOptions).EndPoint, PrivateKey = key, })]; diff --git a/src/console/LibplanetConsole.Console.Executable/EntryCommands/InitializeCommand.cs b/src/console/LibplanetConsole.Console.Executable/EntryCommands/InitializeCommand.cs index 3b6771ee..9b1e0be3 100644 --- a/src/console/LibplanetConsole.Console.Executable/EntryCommands/InitializeCommand.cs +++ b/src/console/LibplanetConsole.Console.Executable/EntryCommands/InitializeCommand.cs @@ -14,9 +14,6 @@ namespace LibplanetConsole.Console.Executable.EntryCommands; [CommandSummary("Create a new repository to run Libplanet nodes and clients from the console.")] internal sealed class InitializeCommand : CommandBase { - private const int RandomPortSpacing = 10; - private readonly List _portList = []; - public InitializeCommand() : base("init") { @@ -95,13 +92,13 @@ public InitializeCommand() [Category("Genesis")] public string ActionProviderType { get; set; } = string.Empty; - [CommandProperty("port-spacing", InitValue = 2)] - [CommandSummary("Specifies the spacing between ports. Default is 2. " + + [CommandProperty("port-spacing", InitValue = PortGenerator.DefaultSpace)] + [CommandSummary("Specifies the spacing between ports. Default is 10. " + "This option is only used when --port-generation-mode is set to " + "'sequential'. If --port-generation-mode is set to 'random', " + - "the value of this option is 5'")] + "the value of this option is 10'")] [Category("Network")] - [Range(1, 10000)] + [Range(10, 10000)] public int PortSpacing { get; set; } [CommandProperty("port-generation-mode")] @@ -111,11 +108,11 @@ public InitializeCommand() protected override void OnExecute() { + var portGenerator = new PortGenerator(Port); var genesisKey = PrivateKeyUtility.ParseOrRandom(GenesisKey); - var port = Port == 0 ? PortUtility.NextPort() : Port; - var nextPort = port; - var nodeOptions = GetNodeOptions(ref nextPort); - var clientOptions = GetClientOptions(ref nextPort); + var port = portGenerator.Current; + var nodeOptions = GetNodeOptions(portGenerator); + var clientOptions = GetClientOptions(portGenerator); var outputPath = Path.GetFullPath(RepositoryPath); var dateTimeOffset = DateTimeOffset != DateTimeOffset.MinValue ? DateTimeOffset : DateTimeOffset.UtcNow; @@ -152,45 +149,7 @@ protected override void OnExecute() TextWriterExtensions.WriteLineAsJson(writer, info); } - private int NextPort(ref int nextPort) - { - nextPort = GetPort(nextPort); - _portList.Add(nextPort); - _portList.Sort(); - return nextPort; - - int GetPort(int nextPort) - { - if (PortGenerationMode == PortGenerationMode.Random) - { - var port = PortUtility.NextPort(); - while (IsValidRandomPort(port) is false) - { - port = PortUtility.NextPort(); - } - - return port; - } - - return nextPort + PortSpacing; - } - } - - private bool IsValidRandomPort(int randomPort) - { - for (var i = 0; i < _portList.Count; i++) - { - var port = _portList[i]; - if (Math.Abs(port - randomPort) < RandomPortSpacing) - { - return false; - } - } - - return true; - } - - private NodeOptions[] GetNodeOptions(ref int nextPort) + private NodeOptions[] GetNodeOptions(PortGenerator portGenerator) { var privateKeys = GetNodes(); var nodeOptionsList = new List(privateKeys.Length); @@ -198,7 +157,7 @@ private NodeOptions[] GetNodeOptions(ref int nextPort) { var nodeOptions = new NodeOptions { - EndPoint = GetLocalHost(NextPort(ref nextPort)), + EndPoint = GetLocalHost(portGenerator.Next()), PrivateKey = privateKey, StorePath = "store", LogPath = "log", @@ -211,7 +170,7 @@ private NodeOptions[] GetNodeOptions(ref int nextPort) return [.. nodeOptionsList]; } - private ClientOptions[] GetClientOptions(ref int nextPort) + private ClientOptions[] GetClientOptions(PortGenerator portGenerator) { var privateKeys = GetClients(); var clientOptionsList = new List(privateKeys.Length); @@ -219,7 +178,7 @@ private ClientOptions[] GetClientOptions(ref int nextPort) { var clientOptions = new ClientOptions { - EndPoint = GetLocalHost(NextPort(ref nextPort)), + EndPoint = GetLocalHost(portGenerator.Next()), PrivateKey = privateKey, LogPath = "log", }; diff --git a/src/console/LibplanetConsole.Console.Executable/Tracers/ClientCollectionEventTracer.cs b/src/console/LibplanetConsole.Console.Executable/Tracers/ClientCollectionEventTracer.cs index bb7860aa..b1e750f5 100644 --- a/src/console/LibplanetConsole.Console.Executable/Tracers/ClientCollectionEventTracer.cs +++ b/src/console/LibplanetConsole.Console.Executable/Tracers/ClientCollectionEventTracer.cs @@ -7,6 +7,7 @@ namespace LibplanetConsole.Console.Executable.Tracers; internal sealed class ClientCollectionEventTracer : IHostedService, IDisposable { private readonly IClientCollection _clients; + private bool _isDisposed; public ClientCollectionEventTracer(IClientCollection clients) { @@ -27,12 +28,16 @@ public Task StopAsync(CancellationToken cancellationToken) void IDisposable.Dispose() { - foreach (var client in _clients) + if (_isDisposed is false) { - DetachEvent(client); - } + foreach (var client in _clients) + { + DetachEvent(client); + } - _clients.CollectionChanged -= Clients_CollectionChanged; + _clients.CollectionChanged -= Clients_CollectionChanged; + _isDisposed = true; + } } private void AttachEvent(IClient client) diff --git a/src/console/LibplanetConsole.Console.Executable/Tracers/NodeCollectionEventTracer.cs b/src/console/LibplanetConsole.Console.Executable/Tracers/NodeCollectionEventTracer.cs index f3390aa9..3e3837f4 100644 --- a/src/console/LibplanetConsole.Console.Executable/Tracers/NodeCollectionEventTracer.cs +++ b/src/console/LibplanetConsole.Console.Executable/Tracers/NodeCollectionEventTracer.cs @@ -10,6 +10,7 @@ internal sealed class NodeCollectionEventTracer : IHostedService, IDisposable private readonly INodeCollection _nodes; private readonly ILogger _logger; private INode? _current; + private bool _isDisposed; public NodeCollectionEventTracer( INodeCollection nodes, ILogger logger) @@ -34,12 +35,16 @@ public Task StopAsync(CancellationToken cancellationToken) void IDisposable.Dispose() { - _nodes.CurrentChanged -= Nodes_CurrentChanged; - _nodes.CollectionChanged -= Nodes_CollectionChanged; - UpdateCurrent(null); - foreach (var node in _nodes) + if (_isDisposed is false) { - DetachEvent(node); + _nodes.CurrentChanged -= Nodes_CurrentChanged; + _nodes.CollectionChanged -= Nodes_CollectionChanged; + foreach (var node in _nodes) + { + DetachEvent(node); + } + + _isDisposed = true; } } @@ -64,6 +69,7 @@ private void AttachEvent(INode node) node.Detached += Node_Detached; node.Started += Node_Started; node.Stopped += Node_Stopped; + node.Disposed += Node_Disposed; } private void DetachEvent(INode node) @@ -72,6 +78,7 @@ private void DetachEvent(INode node) node.Detached -= Node_Detached; node.Started -= Node_Started; node.Stopped -= Node_Stopped; + node.Disposed += Node_Disposed; } private void Nodes_CurrentChanged(object? sender, EventArgs e) @@ -154,4 +161,12 @@ private void Node_Stopped(object? sender, EventArgs e) System.Console.Out.WriteColoredLine(message, colorType); } } + + private void Node_Disposed(object? sender, EventArgs e) + { + if (sender is INode node && node == _current) + { + _current = null; + } + } } diff --git a/src/console/LibplanetConsole.Console/ApplicationOptions.cs b/src/console/LibplanetConsole.Console/ApplicationOptions.cs index ca843d1f..53407b52 100644 --- a/src/console/LibplanetConsole.Console/ApplicationOptions.cs +++ b/src/console/LibplanetConsole.Console/ApplicationOptions.cs @@ -2,6 +2,9 @@ namespace LibplanetConsole.Console; public sealed record class ApplicationOptions { + public const int SeedBlocksyncPortIncrement = 6; + public const int SeedConsensusPortIncrement = 7; + public ApplicationOptions(int port) { Port = port; diff --git a/src/console/LibplanetConsole.Console/Node.cs b/src/console/LibplanetConsole.Console/Node.cs index 690b1ee5..9c6b5e4b 100644 --- a/src/console/LibplanetConsole.Console/Node.cs +++ b/src/console/LibplanetConsole.Console/Node.cs @@ -24,8 +24,6 @@ internal sealed partial class Node : INode, IBlockChain private NodeService? _nodeService; private BlockChainService? _blockChainService; private GrpcChannel? _channel; - private EndPoint? _blocksyncEndPoint; - private EndPoint? _consensusEndPoint; private NodeInfo _nodeInfo; private bool _isDisposed; private NodeProcess? _process; @@ -52,12 +50,6 @@ public Node(IServiceProvider serviceProvider, NodeOptions nodeOptions) public event EventHandler? Disposed; - public EndPoint SwarmEndPoint - => _blocksyncEndPoint ?? throw new InvalidOperationException("Peer is not set."); - - public EndPoint ConsensusEndPoint - => _consensusEndPoint ?? throw new InvalidOperationException("ConsensusPeer is not set."); - public PublicKey PublicKey { get; } public Address Address => PublicKey.Address; @@ -210,8 +202,6 @@ public async Task StartAsync(CancellationToken cancellationToken) var callOptions = new CallOptions(cancellationToken: cancellationToken); var response = await _nodeService.StartAsync(request, callOptions); _nodeInfo = response.NodeInfo; - _blocksyncEndPoint = Parse(_nodeInfo.SwarmEndPoint); - _consensusEndPoint = Parse(_nodeInfo.ConsensusEndPoint); IsRunning = true; _logger.LogDebug("Node is started: {Address}", Address); await Task.WhenAll(Contents.Select(item => item.StartAsync(cancellationToken))); diff --git a/src/console/LibplanetConsole.Console/SeedService.cs b/src/console/LibplanetConsole.Console/SeedService.cs index 0816c091..58a11893 100644 --- a/src/console/LibplanetConsole.Console/SeedService.cs +++ b/src/console/LibplanetConsole.Console/SeedService.cs @@ -3,7 +3,7 @@ namespace LibplanetConsole.Console; -internal sealed class SeedService : ISeedService +internal sealed class SeedService(ApplicationOptions options) : ISeedService { private readonly PrivateKey _seedNodePrivateKey = new(); private SeedNode? _blocksyncSeedNode; @@ -33,12 +33,12 @@ public async Task StartAsync(CancellationToken cancellationToken) _blocksyncSeedNode = new SeedNode(new() { PrivateKey = _seedNodePrivateKey, - Port = PortUtility.NextPort(), + Port = options.Port + ApplicationOptions.SeedBlocksyncPortIncrement, }); _consensusSeedNode = new SeedNode(new() { PrivateKey = _seedNodePrivateKey, - Port = PortUtility.NextPort(), + Port = options.Port + ApplicationOptions.SeedConsensusPortIncrement, }); await _blocksyncSeedNode.StartAsync(cancellationToken); await _consensusSeedNode.StartAsync(cancellationToken); diff --git a/src/node/LibplanetConsole.Node/ApplicationOptions.cs b/src/node/LibplanetConsole.Node/ApplicationOptions.cs index bcf1bb99..372eb224 100644 --- a/src/node/LibplanetConsole.Node/ApplicationOptions.cs +++ b/src/node/LibplanetConsole.Node/ApplicationOptions.cs @@ -2,6 +2,11 @@ namespace LibplanetConsole.Node; public sealed record class ApplicationOptions { + public const int BlocksyncPortIncrement = 4; + public const int ConsensusPortIncrement = 5; + public const int SeedBlocksyncPortIncrement = 6; + public const int SeedConsensusPortIncrement = 7; + public ApplicationOptions(int port, PrivateKey privateKey, byte[] genesis) { Port = port; diff --git a/src/node/LibplanetConsole.Node/Node.cs b/src/node/LibplanetConsole.Node/Node.cs index f49cbbee..01fed2cf 100644 --- a/src/node/LibplanetConsole.Node/Node.cs +++ b/src/node/LibplanetConsole.Node/Node.cs @@ -32,10 +32,10 @@ private readonly SynchronizationContext _synchronizationContext private readonly byte[] _genesis; private readonly AppProtocolVersion _appProtocolVersion = SeedNode.AppProtocolVersion; private readonly IActionProvider _actionProvider; + private readonly int _blocksyncPort; + private readonly int _consensusPort; private EndPoint? _seedEndPoint; - private EndPoint? _blocksyncEndPoint; - private EndPoint? _consensusEndPoint; private Swarm? _swarm; private Task _startTask = Task.CompletedTask; private bool _isDisposed; @@ -50,6 +50,8 @@ public Node(IServiceProvider serviceProvider, ApplicationOptions options) _actionProvider = options.ActionProvider ?? ActionProvider.Default; _logger = serviceProvider.GetLogger(); _genesis = options.Genesis; + _blocksyncPort = options.Port + ApplicationOptions.BlocksyncPortIncrement; + _consensusPort = options.Port + ApplicationOptions.ConsensusPortIncrement; UpdateNodeInfo(); _logger.LogDebug("Node is created: {Address}", Address); } @@ -58,18 +60,6 @@ public Node(IServiceProvider serviceProvider, ApplicationOptions options) public event EventHandler? Stopped; - public EndPoint SwarmEndPoint - { - get => _blocksyncEndPoint ?? throw new InvalidOperationException(); - set => _blocksyncEndPoint = value; - } - - public EndPoint ConsensusEndPoint - { - get => _consensusEndPoint ?? throw new InvalidOperationException(); - set => _consensusEndPoint = value; - } - public string StorePath => _storePath; public bool IsRunning { get; private set; } @@ -152,12 +142,12 @@ public async Task StartAsync(CancellationToken cancellationToken) var privateKey = PrivateKeyUtility.FromSecureString(_privateKey); var appProtocolVersion = _appProtocolVersion; var storePath = _storePath; - var blocksyncEndPoint = _blocksyncEndPoint ?? EndPointUtility.NextEndPoint(); - var consensusEndPoint = _consensusEndPoint ?? EndPointUtility.NextEndPoint(); + var blocksyncPort = _blocksyncPort; + var consensusPort = _consensusPort; var blocksyncSeedPeer = seedInfo.BlocksyncSeedPeer; var consensusSeedPeer = seedInfo.ConsensusSeedPeer; var swarmTransport - = await CreateTransport(privateKey, blocksyncEndPoint, appProtocolVersion); + = await CreateTransport(privateKey, blocksyncPort, appProtocolVersion); var swarmOptions = new SwarmOptions { StaticPeers = [blocksyncSeedPeer], @@ -168,12 +158,12 @@ var swarmTransport }; var consensusTransport = await CreateTransport( privateKey: privateKey, - endPoint: consensusEndPoint, + port: consensusPort, appProtocolVersion: appProtocolVersion); var consensusReactorOption = new ConsensusReactorOption { SeedPeers = [consensusSeedPeer], - ConsensusPort = EndPointUtility.GetHostAndPort(consensusEndPoint).Port, + ConsensusPort = consensusPort, ConsensusPrivateKey = privateKey, TargetBlockInterval = TimeSpan.FromSeconds(2), ContextTimeoutOptions = new(), @@ -184,8 +174,6 @@ var swarmTransport renderer: this, actionProvider: _actionProvider); - _blocksyncEndPoint = blocksyncEndPoint; - _consensusEndPoint = consensusEndPoint; _swarm = new Swarm( blockChain: blockChain, privateKey: privateKey, @@ -220,8 +208,6 @@ public async Task StopAsync(CancellationToken cancellationToken) _logger.LogDebug("Node.Swarm is stopped: {Address}", Address); } - _blocksyncEndPoint = null; - _consensusEndPoint = null; _swarm = null; _startTask = Task.CompletedTask; IsRunning = false; @@ -234,9 +220,6 @@ public async ValueTask DisposeAsync() { if (_isDisposed is false) { - _blocksyncEndPoint = null; - _consensusEndPoint = null; - if (_swarm is not null) { await _swarm.StopAsync(cancellationToken: default); @@ -284,14 +267,13 @@ void Action(object? state) } private static async Task CreateTransport( - PrivateKey privateKey, EndPoint endPoint, AppProtocolVersion appProtocolVersion) + PrivateKey privateKey, int port, AppProtocolVersion appProtocolVersion) { var appProtocolVersionOptions = new AppProtocolVersionOptions { AppProtocolVersion = appProtocolVersion, }; - var (host, port) = EndPointUtility.GetHostAndPort(endPoint); - var hostOptions = new HostOptions(host, [], port); + var hostOptions = new HostOptions("localhost", [], port); return await NetMQTransport.Create(privateKey, appProtocolVersionOptions, hostOptions); } @@ -328,14 +310,14 @@ private void UpdateNodeInfo() ProcessId = Environment.ProcessId, Address = Address, AppProtocolVersion = $"{appProtocolVersion}", + BlocksyncPort = _blocksyncPort, + ConsensusPort = _consensusPort, }; if (IsRunning == true) { nodeInfo = nodeInfo with { - SwarmEndPoint = EndPointUtility.ToString(SwarmEndPoint), - ConsensusEndPoint = EndPointUtility.ToString(ConsensusEndPoint), GenesisHash = BlockChain.Genesis.Hash, Tip = new BlockInfo(BlockChain.Tip), IsRunning = IsRunning, diff --git a/src/node/LibplanetConsole.Node/SeedService.cs b/src/node/LibplanetConsole.Node/SeedService.cs index e96266c5..02fdffce 100644 --- a/src/node/LibplanetConsole.Node/SeedService.cs +++ b/src/node/LibplanetConsole.Node/SeedService.cs @@ -3,7 +3,7 @@ namespace LibplanetConsole.Node; -internal sealed class SeedService : ISeedService +internal sealed class SeedService(ApplicationOptions options) : ISeedService { private readonly PrivateKey _seedNodePrivateKey = new(); private SeedNode? _blocksyncSeedNode; @@ -35,12 +35,12 @@ public async Task StartAsync(CancellationToken cancellationToken) var blocksyncSeedNode = new SeedNode(new() { PrivateKey = _seedNodePrivateKey, - Port = PortUtility.NextPort(), + Port = options.Port + ApplicationOptions.SeedBlocksyncPortIncrement, }); var consensusSeedNode = new SeedNode(new() { PrivateKey = _seedNodePrivateKey, - Port = PortUtility.NextPort(), + Port = options.Port + ApplicationOptions.SeedConsensusPortIncrement, }); await blocksyncSeedNode.StartAsync(cancellationToken); await consensusSeedNode.StartAsync(cancellationToken); diff --git a/src/shared/LibplanetConsole.Node/NodeInfo.cs b/src/shared/LibplanetConsole.Node/NodeInfo.cs index 9198c31a..18a9047b 100644 --- a/src/shared/LibplanetConsole.Node/NodeInfo.cs +++ b/src/shared/LibplanetConsole.Node/NodeInfo.cs @@ -9,9 +9,9 @@ public readonly record struct NodeInfo public string AppProtocolVersion { get; init; } - public string SwarmEndPoint { get; init; } + public int BlocksyncPort { get; init; } - public string ConsensusEndPoint { get; init; } + public int ConsensusPort { get; init; } public Address Address { get; init; } @@ -25,8 +25,6 @@ public readonly record struct NodeInfo { ProcessId = -1, AppProtocolVersion = string.Empty, - SwarmEndPoint = string.Empty, - ConsensusEndPoint = string.Empty, Tip = BlockInfo.Empty, }; @@ -36,8 +34,8 @@ public static implicit operator NodeInfo(NodeInformation nodeInfo) { ProcessId = nodeInfo.ProcessId, AppProtocolVersion = nodeInfo.AppProtocolVersion, - SwarmEndPoint = nodeInfo.SwarmEndPoint, - ConsensusEndPoint = nodeInfo.ConsensusEndPoint, + BlocksyncPort = nodeInfo.BlocksyncPort, + ConsensusPort = nodeInfo.ConsensusPort, Address = new Address(nodeInfo.Address), GenesisHash = BlockHash.FromString(nodeInfo.GenesisHash), Tip = new BlockInfo @@ -56,8 +54,8 @@ public static implicit operator NodeInformation(NodeInfo nodeInfo) { ProcessId = nodeInfo.ProcessId, AppProtocolVersion = nodeInfo.AppProtocolVersion, - SwarmEndPoint = nodeInfo.SwarmEndPoint, - ConsensusEndPoint = nodeInfo.ConsensusEndPoint, + BlocksyncPort = nodeInfo.BlocksyncPort, + ConsensusPort = nodeInfo.ConsensusPort, Address = nodeInfo.Address.ToHex(), GenesisHash = nodeInfo.GenesisHash.ToString(), TipHash = nodeInfo.Tip.Hash.ToString(), diff --git a/src/shared/LibplanetConsole.Node/Protos/NodeGrpcService.proto b/src/shared/LibplanetConsole.Node/Protos/NodeGrpcService.proto index 48331c18..3f9a075b 100644 --- a/src/shared/LibplanetConsole.Node/Protos/NodeGrpcService.proto +++ b/src/shared/LibplanetConsole.Node/Protos/NodeGrpcService.proto @@ -17,8 +17,8 @@ service NodeGrpcService { message NodeInformation { int32 process_id = 1; string app_protocol_version = 2; - string swarm_end_point = 3; - string consensus_end_point = 4; + int32 blocksync_port = 3; + int32 consensus_port = 4; string address = 5; string genesis_hash = 6; string tip_hash = 7;