Rpc: remove not required clone

This commit is contained in:
Kirill Fomichev 2021-09-26 17:17:39 +03:00 committed by Michael Vines
parent 6f08f9decd
commit 9542bae56e
1 changed files with 41 additions and 50 deletions

View File

@ -125,10 +125,8 @@ impl RpcSender for HttpSender {
.body(request_json)
.send()
})
};
}?;
match response {
Ok(response) => {
if !response.status().is_success() {
if response.status() == StatusCode::TOO_MANY_REQUESTS
&& too_many_requests_retries > 0
@ -157,12 +155,10 @@ impl RpcSender for HttpSender {
return Err(response.error_for_status().unwrap_err().into());
}
let response_text = tokio::task::block_in_place(move || response.text())?;
let json: serde_json::Value = serde_json::from_str(&response_text)?;
let mut json =
tokio::task::block_in_place(move || response.json::<serde_json::Value>())?;
if json["error"].is_object() {
return match serde_json::from_value::<RpcErrorObject>(json["error"].clone())
{
return match serde_json::from_value::<RpcErrorObject>(json["error"].clone()) {
Ok(rpc_error_object) => {
let data = match rpc_error_object.code {
rpc_custom_error::JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE => {
@ -200,12 +196,7 @@ impl RpcSender for HttpSender {
.into()),
};
}
return Ok(json["result"].clone());
}
Err(err) => {
return Err(err.into());
}
}
return Ok(json["result"].take());
}
}
}