From 05ca268b65f30cb9adf17e460ea9ff28a061670d Mon Sep 17 00:00:00 2001 From: refcell Date: Sun, 5 Nov 2023 12:17:20 +0100 Subject: [PATCH] move the reqwest client into the eth api inner --- crates/rpc/rpc/src/eth/api/mod.rs | 5 +++++ crates/rpc/rpc/src/eth/api/transactions.rs | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/rpc/rpc/src/eth/api/mod.rs b/crates/rpc/rpc/src/eth/api/mod.rs index c081a9a49304..ef40989df40d 100644 --- a/crates/rpc/rpc/src/eth/api/mod.rs +++ b/crates/rpc/rpc/src/eth/api/mod.rs @@ -139,6 +139,8 @@ where task_spawner, pending_block: Default::default(), blocking_task_pool, + #[cfg(feature = "optimism")] + http_client: reqwest::Client::new(), }; Self { inner: Arc::new(inner) } } @@ -446,4 +448,7 @@ struct EthApiInner { pending_block: Mutex>, /// A pool dedicated to blocking tasks. blocking_task_pool: BlockingTaskPool, + /// An http client for communicating with sequencers. + #[cfg(feature = "optimism")] + http_client: reqwest::Client, } diff --git a/crates/rpc/rpc/src/eth/api/transactions.rs b/crates/rpc/rpc/src/eth/api/transactions.rs index e398dc6f1b0c..2b6efcf5b1da 100644 --- a/crates/rpc/rpc/src/eth/api/transactions.rs +++ b/crates/rpc/rpc/src/eth/api/transactions.rs @@ -982,9 +982,8 @@ where EthApiError::InternalEthError })?; - let client = reqwest::Client::new(); - - client + self.inner + .http_client .post(endpoint) .header(http::header::CONTENT_TYPE, "application/json") .body(body)