Interface IBitswapApi
Data trading module for IPFS. Its purpose is to request blocks from and send blocks to other peers in the network.
Namespace: Ipfs.CoreApi
Assembly: Ipfs.Core.dll
Syntax
public interface IBitswapApi
Remarks
Bitswap has two primary jobs
- Attempt to acquire blocks from the network that have been requested by the client
- Judiciously (though strategically) send blocks in its possession to other peers who want them
Methods
| Improve this Doc View SourceGetAsync(Cid, CancellationToken)
Gets a block from the IPFS network.
Declaration
Task<IDataBlock> GetAsync(Cid id, CancellationToken cancel = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| Cid | id | The Cid of the IDataBlock. |
| 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. |
Remarks
Waits for another peer to supply the block with the id.
LedgerAsync(Peer, CancellationToken)
Gets information on the blocks exchanged with a specific Peer.
Declaration
Task<BitswapLedger> LedgerAsync(Peer peer, CancellationToken cancel = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| Peer | peer | The peer to get information on. If the peer is unknown, then a ledger with zeros is returned. |
| CancellationToken | cancel | Is used to stop the task. When cancelled, the TaskCanceledException is raised. |
Returns
| Type | Description |
|---|---|
| Task<BitswapLedger> | A task that represents the asynchronous operation. The task's value
contains the BitswapLedger for the |
UnwantAsync(Cid, CancellationToken)
Remove the CID from the want list.
Declaration
Task UnwantAsync(Cid id, CancellationToken cancel = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| Cid | id | The content that is no longer needed. |
| CancellationToken | cancel | Is used to stop the task. When cancelled, the TaskCanceledException is raised. |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous operation. |
Remarks
Any outstanding GetAsync(Cid, CancellationToken) for the
id are cancelled.
WantsAsync(MultiHash, CancellationToken)
The blocks that are needed by a peer.
Declaration
Task<IEnumerable<Cid>> WantsAsync(MultiHash peer = null, CancellationToken cancel = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| MultiHash | peer | The id of an IPFS peer. If not specified (e.g. null), then the local peer is used. |
| CancellationToken | cancel | Is used to stop the task. When cancelled, the TaskCanceledException is raised. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<Cid>> | A task that represents the asynchronous operation. The task's value
contains the sequence of blocks needed by the |