From c2514fa52839e2ba628eeb51c8ef4d3f8fa570ef Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Tue, 14 Nov 2023 14:11:28 -0800 Subject: [PATCH] CacheMode::Never instead of filling in head block --- web3_proxy/src/jsonrpc/request_builder.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/web3_proxy/src/jsonrpc/request_builder.rs b/web3_proxy/src/jsonrpc/request_builder.rs index 080f98b9..37eaadff 100644 --- a/web3_proxy/src/jsonrpc/request_builder.rs +++ b/web3_proxy/src/jsonrpc/request_builder.rs @@ -320,7 +320,7 @@ impl ValidatedRequest { app: Option<&App>, authorization: Arc, chain_id: u64, - mut head_block: Option, + head_block: Option, #[cfg(feature = "rdkafka")] kafka_debug_logger: Option>, max_wait: Option, permit: Option, @@ -346,19 +346,16 @@ impl ValidatedRequest { #[cfg(not(feature = "rdkafka"))] let kafka_debug_logger = None; - if head_block.is_none() { - if let Some(app) = app { - head_block = app.head_block_receiver().borrow().clone(); - } - } - // now that kafka has logged the user's original params, we can calculate the cache key - // calculating the cache key might alter the params - - // TODO: modify CacheMode::new to wait for a future block if one is requested! be sure to update head_block too! - let cache_mode = match &mut request { - RequestOrMethod::Request(x) => CacheMode::new(x, head_block.as_ref(), app).await?, - _ => CacheMode::Never, + // calculating the CacheMode might alter the params + let cache_mode = if head_block.is_none() { + CacheMode::Never + } else { + // TODO: modify CacheMode::new to wait for a future block if one is requested! be sure to update head_block too! + match &mut request { + RequestOrMethod::Request(x) => CacheMode::new(x, head_block.as_ref(), app).await?, + _ => CacheMode::Never, + } }; // TODO: what should we do if we want a really short max_wait?