@@ -73,8 +73,8 @@ use genawaiter::sync::{Co, Gen};
7373use iroh_net:: NodeAddr ;
7474use portable_atomic:: { AtomicU64 , Ordering } ;
7575use quic_rpc:: {
76- client:: { BoxStreamSync , BoxedServiceConnection } ,
77- RpcClient ,
76+ client:: { BoxStreamSync , BoxedConnector } ,
77+ Connector , RpcClient ,
7878} ;
7979use serde:: { Deserialize , Serialize } ;
8080use tokio:: io:: { AsyncRead , AsyncReadExt , ReadBuf } ;
@@ -87,6 +87,7 @@ use crate::{
8787 format:: collection:: { Collection , SimpleStore } ,
8888 get:: db:: DownloadProgress as BytesDownloadProgress ,
8989 net_protocol:: BlobDownloadRequest ,
90+ rpc:: proto:: RpcService ,
9091 store:: { BaoBlobSize , ConsistencyCheckProgress , ExportFormat , ExportMode , ValidateProgress } ,
9192 util:: SetTagOption ,
9293 BlobFormat , Hash , Tag ,
@@ -105,20 +106,16 @@ use crate::rpc::proto::blobs::{
105106
106107/// Iroh blobs client.
107108#[ derive( Debug , Clone ) ]
108- pub struct Client <
109- C = BoxedServiceConnection < crate :: rpc:: proto:: RpcService > ,
110- S = crate :: rpc:: proto:: RpcService ,
111- > {
112- pub ( super ) rpc : RpcClient < crate :: rpc:: proto:: RpcService , C , S > ,
109+ pub struct Client < C = BoxedConnector < RpcService > > {
110+ pub ( super ) rpc : RpcClient < RpcService , C > ,
113111}
114112
115- impl < C , S > Client < C , S >
113+ impl < C > Client < C >
116114where
117- S : quic_rpc:: Service ,
118- C : quic_rpc:: ServiceConnection < S > ,
115+ C : Connector < RpcService > ,
119116{
120117 /// Create a new client
121- pub fn new ( rpc : RpcClient < crate :: rpc :: proto :: RpcService , C , S > ) -> Self {
118+ pub fn new ( rpc : RpcClient < RpcService , C > ) -> Self {
122119 Self { rpc }
123120 }
124121
@@ -147,7 +144,7 @@ where
147144 /// A batch is a context in which temp tags are created and data is added to the node. Temp tags
148145 /// are automatically deleted when the batch is dropped, leading to the data being garbage collected
149146 /// unless a permanent tag is created for it.
150- pub async fn batch ( & self ) -> Result < Batch < C , S > > {
147+ pub async fn batch ( & self ) -> Result < Batch < C > > {
151148 let ( updates, mut stream) = self . rpc . bidi ( BatchCreateRequest ) . await ?;
152149 let BatchCreateResponse :: Id ( batch) = stream. next ( ) . await . context ( "expected scope id" ) ??;
153150 let rpc = self . rpc . clone ( ) ;
@@ -457,15 +454,14 @@ where
457454 Ok ( ( ) )
458455 }
459456
460- fn tags_client ( & self ) -> tags:: Client < C , S > {
457+ fn tags_client ( & self ) -> tags:: Client < C > {
461458 tags:: Client :: new ( self . rpc . clone ( ) )
462459 }
463460}
464461
465- impl < C , S > SimpleStore for Client < C , S >
462+ impl < C > SimpleStore for Client < C >
466463where
467- S : quic_rpc:: Service ,
468- C : quic_rpc:: ServiceConnection < S > ,
464+ C : Connector < RpcService > ,
469465{
470466 async fn load ( & self , hash : Hash ) -> anyhow:: Result < Bytes > {
471467 self . read_to_bytes ( hash) . await
@@ -882,26 +878,24 @@ impl Reader {
882878 }
883879
884880 /// todo make private again
885- pub async fn from_rpc_read < C , S > (
886- rpc : & RpcClient < crate :: rpc :: proto :: RpcService , C , S > ,
881+ pub async fn from_rpc_read < C > (
882+ rpc : & RpcClient < RpcService , C > ,
887883 hash : Hash ,
888884 ) -> anyhow:: Result < Self >
889885 where
890- C : quic_rpc:: ServiceConnection < S > ,
891- S : quic_rpc:: Service ,
886+ C : Connector < RpcService > ,
892887 {
893888 Self :: from_rpc_read_at ( rpc, hash, 0 , ReadAtLen :: All ) . await
894889 }
895890
896- async fn from_rpc_read_at < C , S > (
897- rpc : & RpcClient < crate :: rpc :: proto :: RpcService , C , S > ,
891+ async fn from_rpc_read_at < C > (
892+ rpc : & RpcClient < RpcService , C > ,
898893 hash : Hash ,
899894 offset : u64 ,
900895 len : ReadAtLen ,
901896 ) -> anyhow:: Result < Self >
902897 where
903- C : quic_rpc:: ServiceConnection < S > ,
904- S : quic_rpc:: Service ,
898+ C : Connector < RpcService > ,
905899 {
906900 let stream = rpc
907901 . server_streaming ( ReadAtRequest { hash, offset, len } )
@@ -999,20 +993,17 @@ mod tests {
999993 use std:: { path:: Path , sync:: Arc } ;
1000994
1001995 use iroh_net:: { NodeAddr , NodeId } ;
1002- use quic_rpc:: client :: BoxedServiceConnection ;
996+ use quic_rpc:: transport :: { Connector , Listener } ;
1003997 use tokio_util:: task:: AbortOnDropHandle ;
1004998
999+ use super :: RpcService ;
10051000 use crate :: {
10061001 provider:: { CustomEventSender , EventSender } ,
10071002 rpc:: client:: { blobs, tags} ,
10081003 util:: local_pool:: LocalPool ,
10091004 } ;
10101005
1011- type RpcClient = quic_rpc:: RpcClient <
1012- crate :: rpc:: proto:: RpcService ,
1013- BoxedServiceConnection < crate :: rpc:: proto:: RpcService > ,
1014- crate :: rpc:: proto:: RpcService ,
1015- > ;
1006+ type RpcClient = quic_rpc:: RpcClient < RpcService > ;
10161007
10171008 /// An iroh node that just has the blobs transport
10181009 #[ derive( Debug ) ]
@@ -1129,10 +1120,9 @@ mod tests {
11291120 let router = router. spawn ( ) . await ?;
11301121
11311122 // Setup RPC
1132- let ( internal_rpc, controller) =
1133- quic_rpc:: transport:: flume:: service_connection :: < crate :: rpc:: proto:: RpcService > ( 32 ) ;
1134- let controller = quic_rpc:: transport:: boxed:: Connection :: new ( controller) ;
1135- let internal_rpc = quic_rpc:: transport:: boxed:: ServerEndpoint :: new ( internal_rpc) ;
1123+ let ( internal_rpc, controller) = quic_rpc:: transport:: flume:: channel ( 32 ) ;
1124+ let controller = controller. boxed ( ) ;
1125+ let internal_rpc = internal_rpc. boxed ( ) ;
11361126 let internal_rpc = quic_rpc:: RpcServer :: new ( internal_rpc) ;
11371127
11381128 let rpc_server_task: tokio:: task:: JoinHandle < ( ) > = tokio:: task:: spawn ( async move {
0 commit comments