From 6d23071640895d0c81679f47c2c53b2ce82eae07 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Thu, 22 Sep 2022 22:14:24 +0000 Subject: [PATCH] less clones, but still some --- web3_proxy/src/rpcs/blockchain.rs | 2 +- web3_proxy/src/rpcs/connection.rs | 2 +- web3_proxy/src/rpcs/connections.rs | 6 +++--- web3_proxy/src/rpcs/request.rs | 12 ++++++------ web3_proxy/src/rpcs/transactions.rs | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/web3_proxy/src/rpcs/blockchain.rs b/web3_proxy/src/rpcs/blockchain.rs index abdc4e25..5351b1dd 100644 --- a/web3_proxy/src/rpcs/blockchain.rs +++ b/web3_proxy/src/rpcs/blockchain.rs @@ -108,7 +108,7 @@ impl Web3Connections { Some(rpc) => { rpc.wait_for_request_handle(authorization, Duration::from_secs(30)) .await? - .request("eth_getBlockByHash", get_block_params, Level::ERROR.into()) + .request("eth_getBlockByHash", &get_block_params, Level::ERROR.into()) .await? } None => { diff --git a/web3_proxy/src/rpcs/connection.rs b/web3_proxy/src/rpcs/connection.rs index 8aab4def..84b7bb64 100644 --- a/web3_proxy/src/rpcs/connection.rs +++ b/web3_proxy/src/rpcs/connection.rs @@ -209,7 +209,7 @@ impl Web3Connection { .await? .request( "eth_getCode", - ( + &( "0xdead00000000000000000000000000000000beef", maybe_archive_block, ), diff --git a/web3_proxy/src/rpcs/connections.rs b/web3_proxy/src/rpcs/connections.rs index 783ba2c5..20675d12 100644 --- a/web3_proxy/src/rpcs/connections.rs +++ b/web3_proxy/src/rpcs/connections.rs @@ -312,8 +312,8 @@ impl Web3Connections { authorization: Option<&Arc>, active_request_handles: Vec, method: &str, - // TODO: remove this box once i figure out how to do the options params: Option<&serde_json::Value>, + // TODO: remove this box once i figure out how to do the options ) -> Result, ProviderError> { // TODO: if only 1 active_request_handles, do self.try_send_request? @@ -321,7 +321,7 @@ impl Web3Connections { .into_iter() .map(|active_request_handle| async move { let result: Result, _> = active_request_handle - .request(method, params.cloned(), tracing::Level::ERROR.into()) + .request(method, ¶ms.cloned(), tracing::Level::ERROR.into()) .await; result }) @@ -522,7 +522,7 @@ impl Web3Connections { let response_result = active_request_handle .request( &request.method, - request.params.clone(), + &request.params, RequestErrorHandler::SaveReverts(100.0), ) .await; diff --git a/web3_proxy/src/rpcs/request.rs b/web3_proxy/src/rpcs/request.rs index 5e86d340..ae2ec73d 100644 --- a/web3_proxy/src/rpcs/request.rs +++ b/web3_proxy/src/rpcs/request.rs @@ -55,7 +55,7 @@ impl From for RequestErrorHandler { impl AuthorizedRequest { async fn save_revert(self: Arc, method: String, params: T) -> anyhow::Result<()> where - T: fmt::Debug + serde::Serialize + Send + Sync, + T: Clone + fmt::Debug + serde::Serialize + Send + Sync + 'static, { todo!("save the revert to the database"); } @@ -103,7 +103,7 @@ impl OpenRequestHandle { pub async fn request( &self, method: &str, - params: T, + params: &T, error_handler: RequestErrorHandler, ) -> Result where @@ -141,8 +141,8 @@ impl OpenRequestHandle { // TODO: really sucks that we have to clone here let response = match provider { - Web3Provider::Http(provider) => provider.request(method, params.clone()).await, - Web3Provider::Ws(provider) => provider.request(method, params.clone()).await, + Web3Provider::Http(provider) => provider.request(method, params).await, + Web3Provider::Ws(provider) => provider.request(method, params).await, }; if let Err(err) = &response { @@ -174,7 +174,7 @@ impl OpenRequestHandle { let f = self .authorization .clone() - .save_revert(method.to_string(), params); + .save_revert(method.to_string(), params.clone()); tokio::spawn(async move { f.await }); @@ -194,7 +194,7 @@ impl OpenRequestHandle { let f = self .authorization .clone() - .save_revert(method.to_string(), params); + .save_revert(method.to_string(), params.clone()); tokio::spawn(async move { f.await }); } else { diff --git a/web3_proxy/src/rpcs/transactions.rs b/web3_proxy/src/rpcs/transactions.rs index 1668c1f5..a458b1b3 100644 --- a/web3_proxy/src/rpcs/transactions.rs +++ b/web3_proxy/src/rpcs/transactions.rs @@ -30,7 +30,7 @@ impl Web3Connections { handle .request( "eth_getTransactionByHash", - (pending_tx_id,), + &(pending_tx_id,), Level::ERROR.into(), ) .await?