@@ -25,7 +25,7 @@ use crate::{
25
25
Stats ,
26
26
} ,
27
27
provider:: EventSender ,
28
- rpc:: { client:: blobs:: MemClient , RpcHandler } ,
28
+ rpc:: { client:: blobs:: MemClient , MemRpcHandler , RpcHandler } ,
29
29
store:: { GcConfig , Store } ,
30
30
util:: {
31
31
local_pool:: { self , LocalPoolHandle } ,
@@ -63,7 +63,7 @@ pub(crate) struct BlobsInner<S> {
63
63
endpoint : Endpoint ,
64
64
gc_state : Arc < std:: sync:: Mutex < GcState > > ,
65
65
#[ cfg( feature = "rpc" ) ]
66
- pub ( crate ) rpc_handler : Arc < OnceLock < crate :: rpc:: RpcHandler > > ,
66
+ pub ( crate ) rpc_handler : Arc < OnceLock < crate :: rpc:: MemRpcHandler > > ,
67
67
}
68
68
69
69
/// Name used for logging when new node addresses are added from gossip.
@@ -137,15 +137,26 @@ impl<S: crate::store::Store> Builder<S> {
137
137
/// Build the Blobs protocol handler.
138
138
/// You need to provide a local pool handle and an endpoint.
139
139
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 > > {
140
152
let downloader = Downloader :: new ( self . store . clone ( ) , endpoint. clone ( ) , rt. clone ( ) ) ;
141
- let inner = Arc :: new ( BlobsInner :: new (
153
+ Arc :: new ( BlobsInner :: new (
142
154
self . store ,
143
155
rt. clone ( ) ,
144
156
self . events . unwrap_or_default ( ) ,
145
157
downloader,
146
158
endpoint. clone ( ) ,
147
- ) ) ;
148
- Arc :: new ( Blobs { inner } )
159
+ ) )
149
160
}
150
161
}
151
162
@@ -394,6 +405,10 @@ pub struct Blobs {
394
405
}
395
406
396
407
impl Blobs {
408
+ pub ( crate ) fn from_inner < S : Store > ( inner : Arc < BlobsInner < S > > ) -> Self {
409
+ Self { inner }
410
+ }
411
+
397
412
pub fn client ( & self ) -> MemClient {
398
413
self . inner . clone ( ) . client ( )
399
414
}
@@ -466,7 +481,7 @@ impl<S: crate::store::Store> DynBlobs for BlobsInner<S> {
466
481
fn client ( self : Arc < Self > ) -> MemClient {
467
482
let client = self
468
483
. rpc_handler
469
- . get_or_init ( || RpcHandler :: new ( & self ) )
484
+ . get_or_init ( || MemRpcHandler :: new ( & self ) )
470
485
. client
471
486
. clone ( ) ;
472
487
MemClient :: new ( client)
0 commit comments