public static bool AddNode(IConnectionManager connectionManager, IPeerBanning peerBanning, string endpointStr, string command) { IPEndPoint endpoint = endpointStr.ToIPEndPoint(connectionManager.Network.DefaultPort); switch (command) { case "add": if (peerBanning.IsBanned(endpoint)) { throw new InvalidOperationException("Can't perform 'add' for a banned peer."); } connectionManager.AddNodeAddress(endpoint); break; case "remove": connectionManager.RemoveNodeAddress(endpoint); break; case "onetry": if (peerBanning.IsBanned(endpoint)) { throw new InvalidOperationException("Can't connect to a banned peer."); } connectionManager.ConnectAsync(endpoint).GetAwaiter().GetResult(); break; default: throw new ArgumentException("command"); } return(true); }