@@ -23,7 +23,7 @@ public class MerkleNode
23
23
long linksSize ;
24
24
long linksCount ;
25
25
string name ;
26
- MerkleNode [ ] links ;
26
+ IEnumerable < DagLink > links ;
27
27
IpfsClient ipfsClient ;
28
28
29
29
/// <summary>
@@ -46,6 +46,17 @@ public MerkleNode(string hash, string name = null)
46
46
Name = name ;
47
47
}
48
48
49
+ /// <summary>
50
+ /// Creates a new instance of the <see cref="MerkleNode"/> from the
51
+ /// <see cref="DagLink"/>.
52
+ /// </summary>
53
+ /// <param name="link">The link to a node.</param>
54
+ public MerkleNode ( DagLink link )
55
+ {
56
+ Hash = link . Hash ;
57
+ Name = link . Name ;
58
+ }
59
+
49
60
internal IpfsClient IpfsClient
50
61
{
51
62
get
@@ -117,22 +128,13 @@ public long LinksCount
117
128
/// <summary>
118
129
/// TODO
119
130
/// </summary>
120
- public IEnumerable < MerkleNode > Links
131
+ public IEnumerable < DagLink > Links
121
132
{
122
133
get
123
134
{
124
135
if ( links == null )
125
136
{
126
- if ( linksCount == 0 )
127
- {
128
- links = new MerkleNode [ 0 ] ;
129
- }
130
- else
131
- {
132
- var result = IpfsClient . DoCommand < dynamic > ( "object/links" , Hash ) ;
133
- links = ( ( JArray ) result . Links )
134
- . Select ( l => new MerkleNode ( ( string ) l [ "Hash" ] , ( string ) l [ "Name" ] ) ) . ToArray ( ) ;
135
- }
137
+ links = IpfsClient . Object . LinksAsync ( Hash ) . Result ;
136
138
}
137
139
138
140
return links ;
@@ -198,6 +200,8 @@ void GetObjectStats()
198
200
dataSize = stats . DataSize ;
199
201
linksSize = stats . LinksSize ;
200
202
linksCount = stats . NumLinks ;
203
+ if ( linksCount == 0 )
204
+ links = new DagLink [ 0 ] ;
201
205
202
206
hasObjectStats = true ;
203
207
hasBlockStats = true ;
0 commit comments