File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed
Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ use tokio::sync::RwLock;
2929
3030#[ derive( Debug , Clone ) ]
3131pub struct DerivationRequest {
32- pub cache : Cache ,
32+ pub cache : Option < Cache > ,
3333 pub metrics : Arc < Metrics > ,
3434 pub config : Config ,
3535 pub rollup_config : RollupConfig ,
@@ -79,12 +79,15 @@ impl DerivationRequest {
7979
8080 fn http_provider < N : Network > (
8181 url : & str ,
82- cache : Cache ,
82+ cache : Option < Cache > ,
8383 metrics : Arc < Metrics > ,
8484 ) -> RootProvider < N > {
8585 let url = url. parse ( ) . unwrap ( ) ;
8686 let http = Http :: < Client > :: new ( url) ;
87- let http = HttpProxy :: new ( cache, metrics, http) ;
87+ if let Some ( cache) = cache {
88+ let http = HttpProxy :: new ( cache, metrics, http) ;
89+ return RootProvider :: new ( RpcClient :: new ( http, true ) ) ;
90+ }
8891 RootProvider :: new ( RpcClient :: new ( http, true ) )
8992 }
9093
Original file line number Diff line number Diff line change @@ -27,6 +27,13 @@ async fn main() -> anyhow::Result<()> {
2727 . with ( filter)
2828 . init ( ) ;
2929 info ! ( "start optimism preimage-maker" ) ;
30+ let cache = if config. cache_size > 0 {
31+ info ! ( "enable rpc cache with size {}" , config. cache_size) ;
32+ Some ( new_cache ( config. cache_size ) )
33+ } else {
34+ info ! ( "disable rpc cache with size" ) ;
35+ None
36+ } ;
3037
3138 let l2_client = L2Client :: new (
3239 config. l2_rollup_address . to_string ( ) ,
@@ -41,7 +48,7 @@ async fn main() -> anyhow::Result<()> {
4148 DerivationState {
4249 rollup_config : rollup_config. clone ( ) ,
4350 config : config. clone ( ) ,
44- cache : new_cache ( config . cache_size ) ,
51+ cache,
4552 metrics : Arc :: new ( Metrics :: new ( ) ) ,
4653 l2_chain_id : chain_id,
4754 } ,
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ pub struct DerivationState {
2020 pub rollup_config : RollupConfig ,
2121 pub config : Config ,
2222 pub l2_chain_id : u64 ,
23- pub cache : Cache ,
23+ pub cache : Option < Cache > ,
2424 pub metrics : Arc < Metrics > ,
2525}
2626
You can’t perform that action at this time.
0 commit comments