From d50c869df09262efe4598efaa4aeee7b7a484f17 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Wed, 15 Feb 2023 15:37:43 -0800 Subject: [PATCH] dont hold a lock open --- web3_proxy/src/rpcs/one.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/web3_proxy/src/rpcs/one.rs b/web3_proxy/src/rpcs/one.rs index 7603f7e6..be8f9312 100644 --- a/web3_proxy/src/rpcs/one.rs +++ b/web3_proxy/src/rpcs/one.rs @@ -690,7 +690,7 @@ impl Web3Rpc { // TODO: what if we just happened to have this check line up with another restart? // TODO: think more about this - if let Some(client) = &*conn.provider.read().await { + if let Some(client) = conn.provider.read().await.clone() { // health check as a way of keeping this rpc's request_ewma accurate // TODO: do something different if this is a backup server? @@ -711,11 +711,13 @@ impl Web3Rpc { }) { let authorization = authorization.clone(); let conn = conn.clone(); - let x = async move { - conn.try_request_handle(&authorization, None).await - }; - if let Ok(OpenRequestResult::Handle(x)) = x.await { + let x = async move { + conn.try_request_handle(&authorization, Some(client)).await + } + .await; + + if let Ok(OpenRequestResult::Handle(x)) = x { if let Ok(Some(x)) = x .request::<_, Option>( "eth_getTransactionByHash",