@@ -20,6 +20,7 @@ use iroh_blobs::{
20
20
format:: collection:: { Collection , SimpleStore } ,
21
21
get:: db:: DownloadProgress as BytesDownloadProgress ,
22
22
store:: { ConsistencyCheckProgress , ExportFormat , ExportMode , ValidateProgress } ,
23
+ util:: SetTagOption ,
23
24
BlobFormat , Hash , Tag ,
24
25
} ;
25
26
use iroh_net:: NodeAddr ;
@@ -31,12 +32,13 @@ use tokio::io::{AsyncRead, AsyncReadExt, ReadBuf};
31
32
use tokio_util:: io:: { ReaderStream , StreamReader } ;
32
33
use tracing:: warn;
33
34
34
- use crate :: rpc_protocol:: {
35
- BlobAddPathRequest , BlobAddStreamRequest , BlobAddStreamUpdate , BlobConsistencyCheckRequest ,
36
- BlobDeleteBlobRequest , BlobDownloadRequest , BlobExportRequest , BlobListIncompleteRequest ,
37
- BlobListRequest , BlobReadAtRequest , BlobReadAtResponse , BlobValidateRequest ,
38
- CreateCollectionRequest , CreateCollectionResponse , NodeStatusRequest , SetTagOption ,
35
+ use crate :: rpc_protocol:: blobs :: {
36
+ AddPathRequest , AddStreamRequest , AddStreamUpdate , ConsistencyCheckRequest ,
37
+ CreateCollectionRequest , CreateCollectionResponse , DeleteRequest , DownloadRequest ,
38
+ ExportRequest , ListIncompleteRequest , ListRequest , ReadAtRequest , ReadAtResponse ,
39
+ ValidateRequest ,
39
40
} ;
41
+ use crate :: rpc_protocol:: node:: StatusRequest ;
40
42
41
43
use super :: { flatten, tags, Iroh , RpcClient } ;
42
44
@@ -110,7 +112,7 @@ impl Client {
110
112
) -> Result < AddProgress > {
111
113
let stream = self
112
114
. rpc
113
- . server_streaming ( BlobAddPathRequest {
115
+ . server_streaming ( AddPathRequest {
114
116
path,
115
117
in_place,
116
118
tag,
@@ -158,12 +160,12 @@ impl Client {
158
160
input : impl Stream < Item = io:: Result < Bytes > > + Send + Unpin + ' static ,
159
161
tag : SetTagOption ,
160
162
) -> anyhow:: Result < AddProgress > {
161
- let ( mut sink, progress) = self . rpc . bidi ( BlobAddStreamRequest { tag } ) . await ?;
163
+ let ( mut sink, progress) = self . rpc . bidi ( AddStreamRequest { tag } ) . await ?;
162
164
let mut input = input. map ( |chunk| match chunk {
163
- Ok ( chunk) => Ok ( BlobAddStreamUpdate :: Chunk ( chunk) ) ,
165
+ Ok ( chunk) => Ok ( AddStreamUpdate :: Chunk ( chunk) ) ,
164
166
Err ( err) => {
165
167
warn ! ( "Abort send, reason: failed to read from source stream: {err:?}" ) ;
166
- Ok ( BlobAddStreamUpdate :: Abort )
168
+ Ok ( AddStreamUpdate :: Abort )
167
169
}
168
170
} ) ;
169
171
tokio:: spawn ( async move {
@@ -205,7 +207,7 @@ impl Client {
205
207
) -> Result < impl Stream < Item = Result < ValidateProgress > > > {
206
208
let stream = self
207
209
. rpc
208
- . server_streaming ( BlobValidateRequest { repair } )
210
+ . server_streaming ( ValidateRequest { repair } )
209
211
. await ?;
210
212
Ok ( stream. map ( |res| res. map_err ( anyhow:: Error :: from) ) )
211
213
}
@@ -219,7 +221,7 @@ impl Client {
219
221
) -> Result < impl Stream < Item = Result < ConsistencyCheckProgress > > > {
220
222
let stream = self
221
223
. rpc
222
- . server_streaming ( BlobConsistencyCheckRequest { repair } )
224
+ . server_streaming ( ConsistencyCheckRequest { repair } )
223
225
. await ?;
224
226
Ok ( stream. map ( |r| r. map_err ( anyhow:: Error :: from) ) )
225
227
}
@@ -266,7 +268,7 @@ impl Client {
266
268
} = opts;
267
269
let stream = self
268
270
. rpc
269
- . server_streaming ( BlobDownloadRequest {
271
+ . server_streaming ( DownloadRequest {
270
272
hash,
271
273
format,
272
274
nodes,
@@ -295,7 +297,7 @@ impl Client {
295
297
format : ExportFormat ,
296
298
mode : ExportMode ,
297
299
) -> Result < ExportProgress > {
298
- let req = BlobExportRequest {
300
+ let req = ExportRequest {
299
301
hash,
300
302
path : destination,
301
303
format,
@@ -309,13 +311,13 @@ impl Client {
309
311
310
312
/// List all complete blobs.
311
313
pub async fn list ( & self ) -> Result < impl Stream < Item = Result < BlobInfo > > > {
312
- let stream = self . rpc . server_streaming ( BlobListRequest ) . await ?;
314
+ let stream = self . rpc . server_streaming ( ListRequest ) . await ?;
313
315
Ok ( flatten ( stream) )
314
316
}
315
317
316
318
/// List all incomplete (partial) blobs.
317
319
pub async fn list_incomplete ( & self ) -> Result < impl Stream < Item = Result < IncompleteBlobInfo > > > {
318
- let stream = self . rpc . server_streaming ( BlobListIncompleteRequest ) . await ?;
320
+ let stream = self . rpc . server_streaming ( ListIncompleteRequest ) . await ?;
319
321
Ok ( flatten ( stream) )
320
322
}
321
323
@@ -354,7 +356,7 @@ impl Client {
354
356
355
357
/// Delete a blob.
356
358
pub async fn delete_blob ( & self , hash : Hash ) -> Result < ( ) > {
357
- self . rpc . rpc ( BlobDeleteBlobRequest { hash } ) . await ??;
359
+ self . rpc . rpc ( DeleteRequest { hash } ) . await ??;
358
360
Ok ( ( ) )
359
361
}
360
362
@@ -365,7 +367,7 @@ impl Client {
365
367
blob_format : BlobFormat ,
366
368
addr_options : AddrInfoOptions ,
367
369
) -> Result < BlobTicket > {
368
- let mut addr = self . rpc . rpc ( NodeStatusRequest ) . await ??. addr ;
370
+ let mut addr = self . rpc . rpc ( StatusRequest ) . await ??. addr ;
369
371
addr. apply_options ( addr_options) ;
370
372
let ticket = BlobTicket :: new ( addr, hash, blob_format) . expect ( "correct ticket" ) ;
371
373
@@ -791,19 +793,19 @@ impl Reader {
791
793
len : Option < usize > ,
792
794
) -> anyhow:: Result < Self > {
793
795
let stream = rpc
794
- . server_streaming ( BlobReadAtRequest { hash, offset, len } )
796
+ . server_streaming ( ReadAtRequest { hash, offset, len } )
795
797
. await ?;
796
798
let mut stream = flatten ( stream) ;
797
799
798
800
let ( size, is_complete) = match stream. next ( ) . await {
799
- Some ( Ok ( BlobReadAtResponse :: Entry { size, is_complete } ) ) => ( size, is_complete) ,
801
+ Some ( Ok ( ReadAtResponse :: Entry { size, is_complete } ) ) => ( size, is_complete) ,
800
802
Some ( Err ( err) ) => return Err ( err) ,
801
803
Some ( Ok ( _) ) => return Err ( anyhow ! ( "Expected header frame, but got data frame" ) ) ,
802
804
None => return Err ( anyhow ! ( "Expected header frame, but RPC stream was dropped" ) ) ,
803
805
} ;
804
806
805
807
let stream = stream. map ( |item| match item {
806
- Ok ( BlobReadAtResponse :: Data { chunk } ) => Ok ( chunk) ,
808
+ Ok ( ReadAtResponse :: Data { chunk } ) => Ok ( chunk) ,
807
809
Ok ( _) => Err ( io:: Error :: new ( io:: ErrorKind :: Other , "Expected data frame" ) ) ,
808
810
Err ( err) => Err ( io:: Error :: new ( io:: ErrorKind :: Other , format ! ( "{err}" ) ) ) ,
809
811
} ) ;
0 commit comments