@@ -18,12 +18,12 @@ namespace Ipfs.Api
1818 public class BlockInfo
1919 {
2020 /// <summary>
21- /// The <see cref="MultiHash "/> ID of the block.
21+ /// The <see cref="Cid "/> of the block.
2222 /// </summary>
2323 /// <value>
2424 /// The unique ID of the block.
2525 /// </value>
26- public MultiHash Key { get ; set ; }
26+ public Cid Id { get ; set ; }
2727
2828 /// <summary>
2929 /// The serialised size (in bytes) of the block.
@@ -65,16 +65,16 @@ internal BlockApi(IpfsClient ipfs)
6565 /// <param name="cancel">
6666 /// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised.
6767 /// </param>
68- /// <param name="hash ">
69- /// The <see cref="MultiHash "/> of the block.
68+ /// <param name="id ">
69+ /// The <see cref="Cid "/> of the block.
7070 /// </param>
71- public async Task < Block > GetAsync ( MultiHash hash , CancellationToken cancel = default ( CancellationToken ) ) // TODO CID support
71+ public async Task < Block > GetAsync ( Cid id , CancellationToken cancel = default ( CancellationToken ) ) // TODO CID support
7272 {
73- var data = await ipfs . DownloadBytesAsync ( "block/get" , cancel , hash . ToString ( ) ) ;
73+ var data = await ipfs . DownloadBytesAsync ( "block/get" , cancel , id ) ;
7474 return new Block
7575 {
7676 DataBytes = data ,
77- Hash = hash
77+ Id = id
7878 } ;
7979 }
8080
@@ -89,12 +89,12 @@ internal BlockApi(IpfsClient ipfs)
8989 /// </param>
9090 public async Task < Block > PutAsync ( byte [ ] data , CancellationToken cancel = default ( CancellationToken ) )
9191 {
92- var json = await ipfs . UploadAsync ( "block/put" , cancel , data ) ;
93- var info = JsonConvert . DeserializeObject < BlockInfo > ( json ) ;
92+ var json = await ipfs . UploadAsync ( "block/put" , cancel , data ) ;
93+ var info = JObject . Parse ( json ) ;
9494 return new Block
9595 {
9696 DataBytes = data ,
97- Hash = info . Key
97+ Id = ( string ) info [ " Key" ]
9898 } ;
9999 }
100100
@@ -115,15 +115,21 @@ internal BlockApi(IpfsClient ipfs)
115115 /// <summary>
116116 /// Information on a raw <see cref="Block">IPFS block</see>.
117117 /// </summary>
118- /// <param name="hash ">
119- /// The <see cref="MultiHash "/> id of the block.
118+ /// <param name="id ">
119+ /// The <see cref="Cid "/> of the block.
120120 /// </param>
121121 /// <param name="cancel">
122122 /// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised.
123123 /// </param>
124- public Task < BlockInfo > StatAsync ( MultiHash hash , CancellationToken cancel = default ( CancellationToken ) )
124+ public async Task < BlockInfo > StatAsync ( Cid id , CancellationToken cancel = default ( CancellationToken ) )
125125 {
126- return ipfs . DoCommandAsync < BlockInfo > ( "block/stat" , cancel , hash . ToBase58 ( ) ) ;
126+ var json = await ipfs . DoCommandAsync ( "block/stat" , cancel , id ) ;
127+ var info = JObject . Parse ( json ) ;
128+ return new BlockInfo
129+ {
130+ Size = ( long ) info [ "Size" ] ,
131+ Id = ( string ) info [ "Key" ]
132+ } ;
127133 }
128134
129135 /// <summary>
@@ -132,21 +138,21 @@ internal BlockApi(IpfsClient ipfs)
132138 /// <param name="cancel">
133139 /// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised.
134140 /// </param>
135- /// <param name="hash ">
136- /// The <see cref="MultiHash "/> id of the block.
141+ /// <param name="id ">
142+ /// The <see cref="Cid "/> of the block.
137143 /// </param>
138144 /// <param name="ignoreNonexistent">
139- /// If <b>true</b> do not raise exception when <paramref name="hash "/> does not
145+ /// If <b>true</b> do not raise exception when <paramref name="id "/> does not
140146 /// exist. Default value is <b>false</b>.
141147 /// </param>
142148 /// <returns>
143- /// The awaited Task will return the deleted <paramref name="hash "/> or
149+ /// The awaited Task will return the deleted <paramref name="id "/> or
144150 /// <see cref="string.Empty"/> if the hash does not exist and <paramref name="ignoreNonexistent"/>
145151 /// is <b>true</b>.
146152 /// </returns>
147- public async Task < string > RemoveAsync ( MultiHash hash , bool ignoreNonexistent = false , CancellationToken cancel = default ( CancellationToken ) ) // TODO CID support
153+ public async Task < string > RemoveAsync ( Cid id , bool ignoreNonexistent = false , CancellationToken cancel = default ( CancellationToken ) ) // TODO CID support
148154 {
149- var json = await ipfs . DoCommandAsync ( "block/rm" , cancel , hash . ToBase58 ( ) , "force=" + ignoreNonexistent . ToString ( ) . ToLowerInvariant ( ) ) ;
155+ var json = await ipfs . DoCommandAsync ( "block/rm" , cancel , id , "force=" + ignoreNonexistent . ToString ( ) . ToLowerInvariant ( ) ) ;
150156 if ( json . Length == 0 )
151157 return "" ;
152158 var result = JObject . Parse ( json ) ;
0 commit comments