Interface IBlockApi
Manages IPFS blocks.
Namespace: Ipfs.CoreApi
Assembly: Ipfs.Core.dll
Syntax
public interface IBlockApi
Remarks
An IPFS Block is a byte sequence that represents an IPFS Object (i.e. serialized byte buffers). It is useful to talk about them as "blocks" in IBitswapApi and other things that do not care about what is being stored.
Methods
| Improve this Doc View SourceGetAsync(Cid, CancellationToken)
Gets an IPFS block.
Declaration
Task<IDataBlock> GetAsync(Cid id, CancellationToken cancel = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Cid | id | The Cid of the block. |
CancellationToken | cancel | Is used to stop the task. When cancelled, the TaskCanceledException is raised. |
Returns
Type | Description |
---|---|
Task<IDataBlock> | A task that represents the asynchronous get operation. The task's value contains the block's id and data. |
PutAsync(Byte[], String, String, String, Boolean, CancellationToken)
Stores a byte array as an IPFS block.
Declaration
Task<Cid> PutAsync(byte[] data, string contentType = "dag-pb", string multiHash = "sha2-256", string encoding = "base58btc", bool pin = false, CancellationToken cancel = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Byte[] | data | The byte array to send to the IPFS network. |
String | contentType | The content type or format of the |
String | multiHash | |
String | encoding | |
Boolean | pin | If true the block is pinned to local storage and will not be garbage collected. The default is false. |
CancellationToken | cancel | Is used to stop the task. When cancelled, the TaskCanceledException is raised. |
Returns
Type | Description |
---|---|
Task<Cid> | A task that represents the asynchronous put operation. The task's value is the block's Cid. |
PutAsync(Stream, String, String, String, Boolean, CancellationToken)
Stores a stream as an IPFS block.
Declaration
Task<Cid> PutAsync(Stream data, string contentType = "dag-pb", string multiHash = "sha2-256", string encoding = "base58btc", bool pin = false, CancellationToken cancel = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | data | The Stream of data to send to the IPFS network. |
String | contentType | The content type or format of the |
String | multiHash | |
String | encoding | |
Boolean | pin | If true the block is pinned to local storage and will not be garbage collected. The default is false. |
CancellationToken | cancel | Is used to stop the task. When cancelled, the TaskCanceledException is raised. |
Returns
Type | Description |
---|---|
Task<Cid> | A task that represents the asynchronous put operation. The task's value is the block's Cid. |
RemoveAsync(Cid, Boolean, CancellationToken)
Remove an IPFS block.
Declaration
Task<Cid> RemoveAsync(Cid id, bool ignoreNonexistent = false, CancellationToken cancel = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Cid | id | The Cid of the block. |
Boolean | ignoreNonexistent | If true do not raise exception when |
CancellationToken | cancel | Is used to stop the task. When cancelled, the TaskCanceledException is raised. |
Returns
Type | Description |
---|---|
Task<Cid> | The awaited Task will return the deleted |
Remarks
This removes the block from the local cache and does not affect other peers.
StatAsync(Cid, CancellationToken)
Information on an IPFS block.
Declaration
Task<IDataBlock> StatAsync(Cid id, CancellationToken cancel = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Cid | id | The Cid of the block. |
CancellationToken | cancel | Is used to stop the task. When cancelled, the TaskCanceledException is raised. |
Returns
Type | Description |
---|---|
Task<IDataBlock> | A task that represents the asynchronous operation. The task's value contains the block's id and size or null. |
Remarks
Only the local repository is consulted for the block. If id
does not exist, then null is retuned.