Skip to content

Commit

Permalink
Release 0.3.0
Browse files Browse the repository at this point in the history
A full analysis of the Bitswap API was made to bring it in line with Kubo's RPC API.

[Breaking]
GetAsync and UnwantAsync were removed from IBitswapApi. These were not part of Kubo's API, but were intended for custom implementations. To migrate, derive IBitswapApi and add your custom functionality in your library.
The return type for IBlockApi.GetAsync was changed from IDataBlock to byte[], since IDataBlock was removed in 0.2.0. Kubo's RPC API (including the JS implementation) simply returns the buffer, and so are we now.
ILinkedNode was removed as it was not used anywhere in the broader net-ipfs codebase and seems to have been placed there years ago for future plans that were never carried out.
  • Loading branch information
Arlodotexe committed Apr 3, 2024
1 parent bdc52b4 commit 94d9e32
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 56 deletions.
36 changes: 0 additions & 36 deletions src/CoreApi/IBitswapApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,6 @@ namespace Ipfs.CoreApi
/// <seealso href="https://github.com/ipfs/specs/tree/master/bitswap">Bitswap spec</seealso>
public interface IBitswapApi
{
/// <summary>
/// Gets a block from the IPFS network.
/// </summary>
/// <param name="id">
/// The <see cref="Cid"/> of the <see cref="IDataBlock">block</see>.
/// </param>
/// <param name="cancel">
/// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised.
/// </param>
/// <returns>
/// A task that represents the asynchronous get operation. The task's value
/// contains the block's id and data.
/// </returns>
/// <remarks>
/// Waits for another peer to supply the block with the <paramref name="id"/>.
/// </remarks>
Task<IDataBlock> GetAsync(Cid id, CancellationToken cancel = default);

/// <summary>
/// The blocks that are needed by a peer.
/// </summary>
Expand All @@ -60,24 +42,6 @@ public interface IBitswapApi
/// </returns>
Task<IEnumerable<Cid>> WantsAsync(MultiHash? peer = null, CancellationToken cancel = default);

/// <summary>
/// Remove the CID from the want list.
/// </summary>
/// <param name="id">
/// The content that is no longer needed.
/// </param>
/// <param name="cancel">
/// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised.
/// </param>
/// <returns>
/// A task that represents the asynchronous operation.
/// </returns>
/// <remarks>
/// Any outstanding <see cref="GetAsync(Cid, CancellationToken)"/> for the
/// <paramref name="id"/> are cancelled.
/// </remarks>
Task UnwantAsync(Cid id, CancellationToken cancel = default);

/// <summary>
/// Gets information on the blocks exchanged with a specific <see cref="Peer"/>.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/CoreApi/IBlockApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public interface IBlockApi
/// A task that represents the asynchronous get operation. The task's value
/// contains the block's id and data.
/// </returns>
Task<IDataBlock> GetAsync(Cid id, CancellationToken cancel = default);
Task<byte[]> GetAsync(Cid id, CancellationToken cancel = default);

/// <summary>
/// Stores a byte array as an IPFS block.
Expand Down
1 change: 0 additions & 1 deletion src/CoreApi/IDagApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace Ipfs.CoreApi
/// This API supports other IPLD formats, such as cbor, ethereum-block, git, ...
/// </remarks>
/// <seealso cref="IObjectApi"/>
/// <seealso cref="ILinkedNode"/>
/// <seealso href="https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md">Dag API spec</seealso>
public interface IDagApi
{
Expand Down
6 changes: 2 additions & 4 deletions src/IDataBlock.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System.IO;

namespace Ipfs
namespace Ipfs
{
/// <summary>
/// Some data that is stored in IPFS.
/// </summary>
/// <remarks>
/// A <b>DataBlock</b> has an <see cref="Id">unique ID</see>
/// A <b>DataBlock</b> has a unique <see cref="Id">.</see>
/// and some data.
/// <para>
/// It is useful to talk about them as "blocks" in Bitswap
Expand Down
13 changes: 0 additions & 13 deletions src/ILinkedNode.cs

This file was deleted.

10 changes: 9 additions & 1 deletion src/IpfsCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<LangVersion>12.0</LangVersion>

<!-- https://semver.org/spec/v2.0.0.html -->
<Version>0.2.0</Version>
<Version>0.3.0</Version>
<AssemblyVersion>$(Version)</AssemblyVersion>

<!-- Nuget specs -->
Expand All @@ -30,6 +30,14 @@
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReleaseNotes>
--- 0.3.0 ---
A full analysis of the Bitswap API was made to bring it in line with Kubo's RPC API.

[Breaking]
GetAsync and UnwantAsync were removed from IBitswapApi. These were not part of Kubo's API, but were intended for custom implementations. To migrate, derive IBitswapApi and add your custom functionality in your library. See also https://discord.com/channels/806902334369824788/942673321852563456/1225047628602151084.
The return type for IBlockApi.GetAsync was changed from IDataBlock to byte[], since IDataBlock was removed in 0.2.0. Kubo's RPC API (including the JS implementation) simply returns the buffer, and so are we now.
ILinkedNode was removed as it was not used anywhere in the broader net-ipfs codebase and seems to have been placed there years ago for future plans that were never carried out.

--- 0.2.0 ---
[Breaking]
IDataBlock.DataStream was removed. This pattern encouraged async calls behind synchronous property getters, which is a bad practice and can cause deadlocks. Call the async methods directly on the API instead.
Expand Down

0 comments on commit 94d9e32

Please sign in to comment.