@@ -62,8 +62,9 @@ const RPC_BLOB_GET_CHUNK_SIZE: usize = 1024 * 64;
6262const RPC_BLOB_GET_CHANNEL_CAP : usize = 2 ;
6363
6464impl < D : crate :: store:: Store > Blobs < D > {
65- /// Get a client for the blobs protocol
66- pub fn client ( & self ) -> RpcHandler {
65+ /// Spawns an in-memory RPC client and server pair.
66+ #[ must_use = "Dropping the RpcHandler will stop the client" ]
67+ pub fn spawn_rpc ( & self ) -> RpcHandler {
6768 RpcHandler :: new ( self )
6869 }
6970
@@ -870,11 +871,14 @@ impl<D: crate::store::Store> Blobs<D> {
870871 }
871872}
872873
873- /// A rpc handler for the blobs rpc protocol
874+ /// An in memory rpc handler for the blobs rpc protocol
874875///
875876/// This struct contains both a task that handles rpc requests and a client
876- /// that can be used to send rpc requests. Dropping it will stop the handler task,
877- /// so you need to put it somewhere where it will be kept alive.
877+ /// that can be used to send rpc requests.
878+ ///
879+ /// Dropping it will stop the handler task, so you need to put it somewhere
880+ /// where it will be kept alive. This struct will capture a copy of
881+ /// [`crate::net_protocol::Blobs`] and keep it alive.
878882#[ derive( Debug ) ]
879883pub struct RpcHandler {
880884 /// Client to hand out
@@ -902,4 +906,9 @@ impl RpcHandler {
902906 . spawn_accept_loop ( move |req, chan| blobs. clone ( ) . handle_rpc_request ( req, chan) ) ;
903907 Self { client, _handler }
904908 }
909+
910+ /// Get a reference to the rpc client api
911+ pub fn client ( & self ) -> & MemClient {
912+ & self . client
913+ }
905914}
0 commit comments