less clones, but still some

This commit is contained in:
Bryan Stitt 2022-09-22 22:14:24 +00:00
parent 8d011e0cd1
commit 6d23071640
5 changed files with 12 additions and 12 deletions

@ -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 => {

@ -209,7 +209,7 @@ impl Web3Connection {
.await?
.request(
"eth_getCode",
(
&(
"0xdead00000000000000000000000000000000beef",
maybe_archive_block,
),

@ -312,8 +312,8 @@ impl Web3Connections {
authorization: Option<&Arc<AuthorizedRequest>>,
active_request_handles: Vec<OpenRequestHandle>,
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<Box<RawValue>, 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<Box<RawValue>, _> = active_request_handle
.request(method, params.cloned(), tracing::Level::ERROR.into())
.request(method, &params.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;

@ -55,7 +55,7 @@ impl From<Level> for RequestErrorHandler {
impl AuthorizedRequest {
async fn save_revert<T>(self: Arc<Self>, 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<T, R>(
&self,
method: &str,
params: T,
params: &T,
error_handler: RequestErrorHandler,
) -> Result<R, ProviderError>
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 {

@ -30,7 +30,7 @@ impl Web3Connections {
handle
.request(
"eth_getTransactionByHash",
(pending_tx_id,),
&(pending_tx_id,),
Level::ERROR.into(),
)
.await?