Show / Hide Table of Contents

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 Source

GetAsync(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.

| Improve this Doc View Source

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 data; such as "raw" or "dag-db". See MultiCodec for more details.

String multiHash

The MultiHash algorithm name used to produce the Cid.

String encoding

The MultiBase algorithm name used to produce the Cid.

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.

| Improve this Doc View Source

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 data; such as "raw" or "dag-db". See MultiCodec for more details.

String multiHash

The MultiHash algorithm name used to produce the Cid.

String encoding

The MultiBase algorithm name used to produce the Cid.

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.

| Improve this Doc View Source

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 id does not exist. Default value is false.

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 id or null if the id does not exist and ignoreNonexistent is true.

Remarks

This removes the block from the local cache and does not affect other peers.

| Improve this Doc View Source

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.

See Also

IBlockRepositoryApi
Block API spec
  • Improve this Doc
  • View Source
Back to top Generated by DocFX