automatic retry for eth_getTransactionReceipt and eth_getTransactionByHash

thanks for the report Lefteris @ Rotki
This commit is contained in:
Bryan Stitt 2023-05-06 14:17:08 -06:00
parent ffb554d0b3
commit aff53ce36a

@ -1564,6 +1564,37 @@ impl Web3ProxyApp {
JsonRpcForwardedResponse::from_value(json!(gas_estimate), request_id)
}
"eth_getTransactionReceipt" | "eth_getTransactionByHash" => {
// try to get the transaction without specifying a min_block_height
let mut response = self
.balanced_rpcs
.try_proxy_connection(
authorization,
request,
Some(&request_metadata),
None,
None,
)
.await?;
// if we got "null", it is probably because the tx is old. retry requiring nodes with old block data
if let Some(ref result) = response.result {
if result.get() == "null" {
response = self
.balanced_rpcs
.try_proxy_connection(
authorization,
request,
Some(&request_metadata),
Some(&U64::one()),
None,
)
.await?;
}
}
response
}
// TODO: eth_gasPrice that does awesome magic to predict the future
"eth_hashrate" => JsonRpcForwardedResponse::from_value(json!(U64::zero()), request_id),
"eth_mining" => {