/// <summary> /// Will generate and store a new key pair in the local keystore /// </summary> /// <param name="keyName"> /// Name of the key /// </param> /// <param name="keyType"> /// Type of the key to create (ex. rsa, ed25519) /// </param> /// <param name="size"> /// Size of the key to generate /// </param> /// <param name="cancel"> /// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised. /// </param> public async Task <string> Generate(string keyName, string keyType = "rsa", int size = 2048, CancellationToken cancel = default(CancellationToken)) { string json = await ipfs.PostCommandAsync("key/gen", cancel, keyName, $"type={keyType}", $"size={size}"); return(JObject.Parse(json) .Value <string>("ID")); }
/// <summary> /// Create a new MerkleDAG node, using a specific layout. /// </summary> /// <param name="template"><b>null</b> or "unixfs-dir".</param> /// <param name="cancel"> /// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised. /// </param> /// <returns></returns> /// <remarks> /// Caveat: So far, only UnixFS object layouts are supported. /// </remarks> public async Task <DagNode> NewAsync(string template = null, CancellationToken cancel = default(CancellationToken)) { var json = await ipfs.PostCommandAsync("object/new", cancel, template); var hash = (string)(JObject.Parse(json)["Hash"]); return(await GetAsync(hash)); }
/// <summary> /// Create a new MerkleDAG node, using a specific layout. /// </summary> /// <param name="template"><b>null</b> or "unixfs-dir".</param> /// <returns></returns> /// <remarks> /// Caveat: So far, only UnixFS object layouts are supported. /// </remarks> public async Task <DagNode> NewAsync(string template = null) { var json = await ipfs.PostCommandAsync("object/new", template); var hash = (string)(JObject.Parse(json)["Hash"]); return(await GetAsync(hash)); }
/// <summary> /// Publish a message to a given topic. /// </summary> /// <param name="topic"> /// The topic name. /// </param> /// <param name="message"> /// The message to publish. /// </param> /// <param name="cancel"> /// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised. /// </param> public async Task Publish(string topic, string message, CancellationToken cancel = default(CancellationToken)) { var _ = await ipfs.PostCommandAsync("pubsub/pub", cancel, topic, "arg=" + message); return; }
/// <summary> /// Will explictly add a peer for ipfs to connect with /// </summary> /// <param name="peer"> /// Peer information to be added /// </param> /// <param name="cancel"> /// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised. /// </param> /// <returns></returns> public async Task AddPeer(Peer peer, CancellationToken cancel = default(CancellationToken)) { await ipfs.PostCommandAsync("bootstrap/add", cancel, peer.ToString()); }
/// <summary> /// Adds or replaces a configuration value. /// </summary> /// <param name="key"> /// The key name, such as "Addresses.API". /// </param> /// <param name="value"> /// The new <see cref="string"/> value of the <paramref name="key"/>. /// </param> public async Task SetAsync(string key, string value) { var _ = await ipfs.PostCommandAsync("config", key, "arg=" + value); return; }
/// <summary> /// Adds or replaces a configuration value. /// </summary> /// <param name="key"> /// The key name, such as "Addresses.API". /// </param> /// <param name="value"> /// The new <see cref="string"/> value of the <paramref name="key"/>. /// </param> /// <param name="cancel"> /// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised. /// </param> public async Task SetAsync(string key, string value, CancellationToken cancel = default(CancellationToken)) { var _ = await ipfs.PostCommandAsync("config", cancel, key, "arg=" + value); return; }