Skip to content

Commit

Permalink
feat(IObjectApi): add StatAsync, closes #92
Browse files Browse the repository at this point in the history
  • Loading branch information
richardschneider committed Aug 29, 2019
1 parent f0efcf5 commit 0d78ecb
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/CoreApi/IObjectApi.cs
Expand Up @@ -66,6 +66,21 @@ public interface IObjectApi
/// </returns>
Task<DagNode> GetAsync(Cid id, CancellationToken cancel = default(CancellationToken));

/// <summary>
/// Information on a MerkleDag node.
/// </summary>
/// <param name="id">
/// The <see cref="Cid"/> of the node.
/// </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. The task's value
/// contains the <see cref="ObjectStat"/>.
/// </returns>
Task<ObjectStat> StatAsync(Cid id, CancellationToken cancel = default(CancellationToken));

/// <summary>
/// Store a MerkleDAG node.
/// </summary>
Expand Down
38 changes: 38 additions & 0 deletions src/CoreApi/ObjectStat.cs
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Ipfs.CoreApi
{
/// <summary>
/// Information on a DAG node.
/// </summary>
/// <seealso cref="IObjectApi"/>
public class ObjectStat
{
/// <summary>
/// Number of links.
/// </summary>
public int LinkCount { get; set; }

/// <summary>
/// Size of the links segment.
/// </summary>
public long LinkSize { get; set; }

/// <summary>
/// Size of the raw, encoded data.
/// </summary>
public long BlockSize { get; set; }

/// <summary>
/// Siz of the data segment.
/// </summary>
public long DataSize { get; set; }

/// <summary>
/// Size of object and its references
/// </summary>
public long CumulativeSize { get; set; }
}
}

0 comments on commit 0d78ecb

Please sign in to comment.