public Task RemovePeer(Estuary.Actors.Peer peer)
        {
            var dir = PeerDirectory(peer.Address, peer.AddressPort);

            if (System.IO.Directory.Exists(dir))
            {
                System.IO.Directory.Delete(dir);
            }
            return(Task.CompletedTask);
        }
 public async Task AddPeer(Estuary.Actors.Peer peer)
 {
     if (_strings.ValidHandleRegex.IsMatch(peer.name))
     {
         var dir = PeerDirectory(peer.Address, peer.AddressPort);
         System.IO.Directory.CreateDirectory(dir);
         using (var stream = new FileStream($"{dir}/peer.json", FileMode.CreateNew))
         {
             await JsonSerializer.SerializeAsync(stream, peer);
         }
     }
     else
     {
         throw new ArgumentException("Peer display name is invalid", nameof(peer.name));
     }
 }
        public async Task <Estuary.Actors.Peer> GetPeer(SavedIPAddressModel address, int?port = null)
        {
            port = port ?? 443;
            var dir = PeerDirectory(address, port);

            if (System.IO.Directory.Exists(dir))
            {
                Estuary.Actors.Peer peer = null;
                using (var stream = new FileStream($"{dir}/peer.json", FileMode.Open))
                {
                    peer = await JsonSerializer.DeserializeAsync <Estuary.Actors.Peer>(stream);
                }

                return(peer);
            }
            else
            {
                return(null);
            }
        }
 public async Task ReplacePeer(Estuary.Actors.Peer peer)
 {
     await RemovePeer(peer);
     await AddPeer(peer);
 }