Ejemplo n.º 1
0
        public async Task <IEnumerable <Peer> > FindProvidersAsync(Cid id, int limit = 20, Action <Peer> providerFound = null, CancellationToken cancel = default(CancellationToken))
        {
            // TODO: providerFound action
            var stream = await ipfs.DownloadAsync("dht/findprovs", cancel, id, $"num-providers={limit}");

            return(ProviderFromStream(stream, limit));
        }
Ejemplo n.º 2
0
        public async Task SubscribeAsync(string topic, Action <IPublishedMessage> handler, CancellationToken cancellationToken)
        {
            var messageStream = await ipfs.DownloadAsync("pubsub/sub", cancellationToken, topic);

            var sr = new StreamReader(messageStream);

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            Task.Run(() => ProcessMessages(topic, handler, sr, cancellationToken));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

            return;
        }
Ejemplo n.º 3
0
 public Task <Stream> DataAsync(Cid id, CancellationToken cancel = default(CancellationToken))
 {
     return(ipfs.DownloadAsync("object/data", cancel, id));
 }
 /// <summary>
 ///   Opens an existing IPFS file for reading.
 /// </summary>
 /// <param name="path">
 ///   A path to an existing file, such as "QmXarR6rgkQ2fDSHjSY5nM2kuCXKYGViky5nohtwgF65Ec/about"
 ///   or "QmZTR5bcpQD7cFgTorqxZDYaew1Wqgfbd2ud9QqGPAkK2V"
 /// </param>
 /// <param name="cancel">
 ///   Is used to stop the task.  When cancelled, the <see cref="TaskCanceledException"/> is raised.
 /// </param>
 /// <returns>
 ///   A <see cref="Stream"/> to the file contents.
 /// </returns>
 public Task <Stream> ReadFileAsync(string path, CancellationToken cancel = default(CancellationToken))
 {
     return(ipfs.DownloadAsync("cat", cancel, path));
 }