1- use crate :: { BlockExtractorConfig , block_data :: BlockExtractor } ;
1+ use crate :: { BlobCacher , BlobFetcher , BlobFetcherConfig } ;
22use init4_bin_base:: utils:: calc:: SlotCalculator ;
33use reth:: transaction_pool:: TransactionPool ;
44use url:: Url ;
55
6- /// Errors that can occur while building the [`BlockExtractor `] with a
7- /// [`BlockExtractorBuilder `].
6+ /// Errors that can occur while building the [`BlobFetcher `] with a
7+ /// [`BlobFetcherBuilder `].
88#[ derive( Debug , thiserror:: Error ) ]
99pub enum BuilderError {
1010 /// The transaction pool was not provided.
@@ -27,9 +27,9 @@ pub enum BuilderError {
2727 MissingSlotCalculator ,
2828}
2929
30- /// Builder for the [`BlockExtractor `].
30+ /// Builder for the [`BlobFetcher `].
3131#[ derive( Debug , Default , Clone ) ]
32- pub struct BlockExtractorBuilder < Pool > {
32+ pub struct BlobFetcherBuilder < Pool > {
3333 pool : Option < Pool > ,
3434 explorer_url : Option < String > ,
3535 client : Option < reqwest:: Client > ,
@@ -38,10 +38,10 @@ pub struct BlockExtractorBuilder<Pool> {
3838 slot_calculator : Option < SlotCalculator > ,
3939}
4040
41- impl < Pool > BlockExtractorBuilder < Pool > {
41+ impl < Pool > BlobFetcherBuilder < Pool > {
4242 /// Set the transaction pool to use for the extractor.
43- pub fn with_pool < P2 > ( self , pool : P2 ) -> BlockExtractorBuilder < P2 > {
44- BlockExtractorBuilder {
43+ pub fn with_pool < P2 > ( self , pool : P2 ) -> BlobFetcherBuilder < P2 > {
44+ BlobFetcherBuilder {
4545 pool : Some ( pool) ,
4646 explorer_url : self . explorer_url ,
4747 client : self . client ,
@@ -53,15 +53,13 @@ impl<Pool> BlockExtractorBuilder<Pool> {
5353
5454 /// Set the transaction pool to use a mock test pool.
5555 #[ cfg( feature = "test-utils" ) ]
56- pub fn with_test_pool (
57- self ,
58- ) -> BlockExtractorBuilder < reth_transaction_pool:: test_utils:: TestPool > {
56+ pub fn with_test_pool ( self ) -> BlobFetcherBuilder < reth_transaction_pool:: test_utils:: TestPool > {
5957 self . with_pool ( reth_transaction_pool:: test_utils:: testing_pool ( ) )
6058 }
6159
6260 /// Set the configuration for the CL url, pylon url, from the provided
63- /// [`BlockExtractorConfig `].
64- pub fn with_config ( self , config : & BlockExtractorConfig ) -> Result < Self , BuilderError > {
61+ /// [`BlobFetcherConfig `].
62+ pub fn with_config ( self , config : & BlobFetcherConfig ) -> Result < Self , BuilderError > {
6563 let this = self . with_explorer_url ( config. blob_explorer_url ( ) ) ;
6664 let this =
6765 if let Some ( cl_url) = config. cl_url ( ) { this. with_cl_url ( cl_url) ? } else { this } ;
@@ -114,22 +112,22 @@ impl<Pool> BlockExtractorBuilder<Pool> {
114112 pub const fn with_slot_calculator (
115113 mut self ,
116114 slot_calculator : SlotCalculator ,
117- ) -> BlockExtractorBuilder < Pool > {
115+ ) -> BlobFetcherBuilder < Pool > {
118116 self . slot_calculator = Some ( slot_calculator) ;
119117 self
120118 }
121119
122120 /// Set the slot calculator to use for the extractor, using the Pecornino
123121 /// host configuration.
124- pub const fn with_pecornino_slots ( mut self ) -> BlockExtractorBuilder < Pool > {
122+ pub const fn with_pecornino_slots ( mut self ) -> BlobFetcherBuilder < Pool > {
125123 self . slot_calculator = Some ( SlotCalculator :: pecorino_host ( ) ) ;
126124 self
127125 }
128126}
129127
130- impl < Pool : TransactionPool > BlockExtractorBuilder < Pool > {
131- /// Build the [`BlockExtractor `] with the provided parameters.
132- pub fn build ( self ) -> Result < BlockExtractor < Pool > , BuilderError > {
128+ impl < Pool : TransactionPool > BlobFetcherBuilder < Pool > {
129+ /// Build the [`BlobFetcher `] with the provided parameters.
130+ pub fn build ( self ) -> Result < BlobFetcher < Pool > , BuilderError > {
133131 let pool = self . pool . ok_or ( BuilderError :: MissingPool ) ?;
134132
135133 let explorer_url = self . explorer_url . ok_or ( BuilderError :: MissingExplorerUrl ) ?;
@@ -145,7 +143,16 @@ impl<Pool: TransactionPool> BlockExtractorBuilder<Pool> {
145143
146144 let slot_calculator = self . slot_calculator . ok_or ( BuilderError :: MissingSlotCalculator ) ?;
147145
148- Ok ( BlockExtractor :: new ( pool, explorer, client, cl_url, pylon_url, slot_calculator) )
146+ Ok ( BlobFetcher :: new ( pool, explorer, client, cl_url, pylon_url, slot_calculator) )
147+ }
148+
149+ /// Build a [`BlobCacher`] with the provided parameters.
150+ pub fn build_cache ( self ) -> Result < BlobCacher < Pool > , BuilderError >
151+ where
152+ Pool : ' static ,
153+ {
154+ let fetcher = self . build ( ) ?;
155+ Ok ( BlobCacher :: new ( fetcher) )
149156 }
150157}
151158
0 commit comments