public void OnConsoleCommandPeersLayout(string[] args) { if (args.Length == 0) { BConsole.Warning("n value require! usage: peers.layout(16)"); return; } byte n = 0; try { n = Convert.ToByte(args[0]); } catch (Exception e) { BConsole.Error($"convert n exception! e={e.Message}"); return; } // define layout ElasticLayout layout = ElasticLayout.DefineLayout(Peers.Count, n); for (byte x = 1; x <= layout.X; x++) { for (byte y = 1; y <= layout.Y; y++) { for (byte z = 1; z <= layout.Z; z++) { Elastic3D coordinates = new Elastic3D(x, y, z); string[] peers = Peers.ToArray <string>(coordinates, layout); BConsole.WriteLine(ConsoleColor.DarkCyan, $"Coordinates{coordinates.ToString()}: nPeers={peers.Length}"); foreach (var peer in peers) { BConsole.WriteLine($" {peer}"); } } } } BConsole.WriteLine(ConsoleColor.DarkCyan, $"ElasticLayout.DefineLayout({Peers.Count},{n})={layout.ToString()}"); }
private void OnConsoleCommandPeersLayout(string[] args) { byte n = Env.Value <byte>("n", 4); if (args.Length > 0) { byte.TryParse(args[0], out n); } // define layout ElasticLayout layout = ElasticLayout.DefineLayout(Peers.Count, n); for (byte x = 1; x <= layout.X; x++) { for (byte y = 1; y <= layout.Y; y++) { for (byte z = 1; z <= layout.Z; z++) { Elastic3D coordinates = new Elastic3D(x, y, z); string[] peers = Peers.ToArray <string>(coordinates, layout); BConsole.WriteLine(ConsoleColor.DarkCyan, $"Coordinates{coordinates.ToString()}: nPeers={peers.Length}"); foreach (var peer in peers) { BConsole.WriteLine(EndPoint.ToString() == peer?ConsoleColor.Yellow : ConsoleColor.Gray, $" {peer}"); } } } } BConsole.WriteLine(ConsoleColor.DarkCyan, $"ElasticLayout.DefineLayout({Peers.Count},{n})={layout.ToString()}"); }