@@ -25,7 +25,7 @@ use crate::{
2525 Stats ,
2626 } ,
2727 provider:: EventSender ,
28- rpc:: { client:: blobs:: MemClient , RpcHandler } ,
28+ rpc:: { client:: blobs:: MemClient , MemRpcHandler , RpcHandler } ,
2929 store:: { GcConfig , Store } ,
3030 util:: {
3131 local_pool:: { self , LocalPoolHandle } ,
@@ -63,7 +63,7 @@ pub(crate) struct BlobsInner<S> {
6363 endpoint : Endpoint ,
6464 gc_state : Arc < std:: sync:: Mutex < GcState > > ,
6565 #[ cfg( feature = "rpc" ) ]
66- pub ( crate ) rpc_handler : Arc < OnceLock < crate :: rpc:: RpcHandler > > ,
66+ pub ( crate ) rpc_handler : Arc < OnceLock < crate :: rpc:: MemRpcHandler > > ,
6767}
6868
6969/// Name used for logging when new node addresses are added from gossip.
@@ -137,15 +137,26 @@ impl<S: crate::store::Store> Builder<S> {
137137 /// Build the Blobs protocol handler.
138138 /// You need to provide a local pool handle and an endpoint.
139139 pub fn build ( self , rt : & LocalPoolHandle , endpoint : & Endpoint ) -> Arc < Blobs > {
140+ let inner = self . build_inner ( rt, endpoint) ;
141+ Arc :: new ( Blobs { inner } )
142+ }
143+
144+ pub fn build_rpc_handler ( self , rt : & LocalPoolHandle , endpoint : & Endpoint ) -> RpcHandler < S > {
145+ let inner = self . build_inner ( rt, endpoint) ;
146+ RpcHandler :: from_blobs ( inner)
147+ }
148+
149+ /// Build the Blobs protocol handler.
150+ /// You need to provide a local pool handle and an endpoint.
151+ fn build_inner ( self , rt : & LocalPoolHandle , endpoint : & Endpoint ) -> Arc < BlobsInner < S > > {
140152 let downloader = Downloader :: new ( self . store . clone ( ) , endpoint. clone ( ) , rt. clone ( ) ) ;
141- let inner = Arc :: new ( BlobsInner :: new (
153+ Arc :: new ( BlobsInner :: new (
142154 self . store ,
143155 rt. clone ( ) ,
144156 self . events . unwrap_or_default ( ) ,
145157 downloader,
146158 endpoint. clone ( ) ,
147- ) ) ;
148- Arc :: new ( Blobs { inner } )
159+ ) )
149160 }
150161}
151162
@@ -394,6 +405,10 @@ pub struct Blobs {
394405}
395406
396407impl Blobs {
408+ pub ( crate ) fn from_inner < S : Store > ( inner : Arc < BlobsInner < S > > ) -> Self {
409+ Self { inner }
410+ }
411+
397412 pub fn client ( & self ) -> MemClient {
398413 self . inner . clone ( ) . client ( )
399414 }
@@ -466,7 +481,7 @@ impl<S: crate::store::Store> DynBlobs for BlobsInner<S> {
466481 fn client ( self : Arc < Self > ) -> MemClient {
467482 let client = self
468483 . rpc_handler
469- . get_or_init ( || RpcHandler :: new ( & self ) )
484+ . get_or_init ( || MemRpcHandler :: new ( & self ) )
470485 . client
471486 . clone ( ) ;
472487 MemClient :: new ( client)
0 commit comments