1
- use crate :: { BlockExtractorConfig , block_data :: BlockExtractor } ;
1
+ use crate :: { BlobCacher , BlobFetcher , BlobFetcherConfig } ;
2
2
use init4_bin_base:: utils:: calc:: SlotCalculator ;
3
3
use reth:: transaction_pool:: TransactionPool ;
4
4
use url:: Url ;
5
5
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 `].
8
8
#[ derive( Debug , thiserror:: Error ) ]
9
9
pub enum BuilderError {
10
10
/// The transaction pool was not provided.
@@ -27,9 +27,9 @@ pub enum BuilderError {
27
27
MissingSlotCalculator ,
28
28
}
29
29
30
- /// Builder for the [`BlockExtractor `].
30
+ /// Builder for the [`BlobFetcher `].
31
31
#[ derive( Debug , Default , Clone ) ]
32
- pub struct BlockExtractorBuilder < Pool > {
32
+ pub struct BlobFetcherBuilder < Pool > {
33
33
pool : Option < Pool > ,
34
34
explorer_url : Option < String > ,
35
35
client : Option < reqwest:: Client > ,
@@ -38,10 +38,10 @@ pub struct BlockExtractorBuilder<Pool> {
38
38
slot_calculator : Option < SlotCalculator > ,
39
39
}
40
40
41
- impl < Pool > BlockExtractorBuilder < Pool > {
41
+ impl < Pool > BlobFetcherBuilder < Pool > {
42
42
/// 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 {
45
45
pool : Some ( pool) ,
46
46
explorer_url : self . explorer_url ,
47
47
client : self . client ,
@@ -53,15 +53,13 @@ impl<Pool> BlockExtractorBuilder<Pool> {
53
53
54
54
/// Set the transaction pool to use a mock test pool.
55
55
#[ 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 > {
59
57
self . with_pool ( reth_transaction_pool:: test_utils:: testing_pool ( ) )
60
58
}
61
59
62
60
/// 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 > {
65
63
let this = self . with_explorer_url ( config. blob_explorer_url ( ) ) ;
66
64
let this =
67
65
if let Some ( cl_url) = config. cl_url ( ) { this. with_cl_url ( cl_url) ? } else { this } ;
@@ -114,22 +112,22 @@ impl<Pool> BlockExtractorBuilder<Pool> {
114
112
pub const fn with_slot_calculator (
115
113
mut self ,
116
114
slot_calculator : SlotCalculator ,
117
- ) -> BlockExtractorBuilder < Pool > {
115
+ ) -> BlobFetcherBuilder < Pool > {
118
116
self . slot_calculator = Some ( slot_calculator) ;
119
117
self
120
118
}
121
119
122
120
/// Set the slot calculator to use for the extractor, using the Pecornino
123
121
/// host configuration.
124
- pub const fn with_pecornino_slots ( mut self ) -> BlockExtractorBuilder < Pool > {
122
+ pub const fn with_pecornino_slots ( mut self ) -> BlobFetcherBuilder < Pool > {
125
123
self . slot_calculator = Some ( SlotCalculator :: pecorino_host ( ) ) ;
126
124
self
127
125
}
128
126
}
129
127
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 > {
133
131
let pool = self . pool . ok_or ( BuilderError :: MissingPool ) ?;
134
132
135
133
let explorer_url = self . explorer_url . ok_or ( BuilderError :: MissingExplorerUrl ) ?;
@@ -145,7 +143,16 @@ impl<Pool: TransactionPool> BlockExtractorBuilder<Pool> {
145
143
146
144
let slot_calculator = self . slot_calculator . ok_or ( BuilderError :: MissingSlotCalculator ) ?;
147
145
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) )
149
156
}
150
157
}
151
158
0 commit comments