Skip to content

Commit 0d78ecb

Browse files
feat(IObjectApi): add StatAsync, closes #92
1 parent f0efcf5 commit 0d78ecb

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

src/CoreApi/IObjectApi.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ public interface IObjectApi
6666
/// </returns>
6767
Task<DagNode> GetAsync(Cid id, CancellationToken cancel = default(CancellationToken));
6868

69+
/// <summary>
70+
/// Information on a MerkleDag node.
71+
/// </summary>
72+
/// <param name="id">
73+
/// The <see cref="Cid"/> of the node.
74+
/// </param>
75+
/// <param name="cancel">
76+
/// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised.
77+
/// </param>
78+
/// <returns>
79+
/// A task that represents the asynchronous operation. The task's value
80+
/// contains the <see cref="ObjectStat"/>.
81+
/// </returns>
82+
Task<ObjectStat> StatAsync(Cid id, CancellationToken cancel = default(CancellationToken));
83+
6984
/// <summary>
7085
/// Store a MerkleDAG node.
7186
/// </summary>

src/CoreApi/ObjectStat.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Ipfs.CoreApi
6+
{
7+
/// <summary>
8+
/// Information on a DAG node.
9+
/// </summary>
10+
/// <seealso cref="IObjectApi"/>
11+
public class ObjectStat
12+
{
13+
/// <summary>
14+
/// Number of links.
15+
/// </summary>
16+
public int LinkCount { get; set; }
17+
18+
/// <summary>
19+
/// Size of the links segment.
20+
/// </summary>
21+
public long LinkSize { get; set; }
22+
23+
/// <summary>
24+
/// Size of the raw, encoded data.
25+
/// </summary>
26+
public long BlockSize { get; set; }
27+
28+
/// <summary>
29+
/// Siz of the data segment.
30+
/// </summary>
31+
public long DataSize { get; set; }
32+
33+
/// <summary>
34+
/// Size of object and its references
35+
/// </summary>
36+
public long CumulativeSize { get; set; }
37+
}
38+
}

0 commit comments

Comments
 (0)