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.PostDownloadAsync("dht/findprovs", cancel, id, $"num-providers={limit}"); return(ProviderFromStream(stream, limit)); }
public async Task SubscribeAsync(string topic, Action <IPublishedMessage> handler, CancellationToken cancellationToken) { var messageStream = await ipfs.PostDownloadAsync("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; }
/// <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.PostDownloadAsync("cat", cancel, path)); }
public Task <Stream> DataAsync(Cid id, CancellationToken cancel = default(CancellationToken)) { return(ipfs.PostDownloadAsync("object/data", cancel, id)); }