/// <summary> /// Creates a new node, loading the database and server identity /// from the provided path. /// </summary> public static async Task <Node> Create(string folder, Binding binding, int port) { if (!Directory.Exists(folder)) { throw new Exception("Path is not a folder!"); } var privateIdentity = await LoadIdentity(folder); var address = await AddressFromBinding(binding); var databaseHandler = await APIGateway.Create(Path.Combine(folder, "hostanode.db"), privateIdentity, port); Console.WriteLine($"Creating node with location {privateIdentity.ID}:{address}:{port}"); return(new Node(privateIdentity, new IPEndPoint(address, port), databaseHandler)); }
/// <summary> /// Creates a new instance of a Node. /// </summary> private Node(PrivateIdentity identity, IPEndPoint endpoint, APIGateway dataBaseHandler) { databaseHandler = dataBaseHandler; gateway = new APITranslationServer(identity, endpoint, databaseHandler); }