Skip to content

Commit

Permalink
Enable RPC retries (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
intoverflow authored Oct 19, 2023
1 parent 78880e5 commit ddb349b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/src/host/provider/rpc_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@

use anyhow::{anyhow, Result};
use ethers_core::types::{Block, Bytes, EIP1186ProofResponse, Transaction, H256, U256};
use ethers_providers::{Http, Middleware};
use ethers_providers::{Http, Middleware, RetryClient};
use log::info;

use super::{AccountQuery, BlockQuery, ProofQuery, Provider, StorageQuery};

pub struct RpcProvider {
http_client: ethers_providers::Provider<Http>,
http_client: ethers_providers::Provider<RetryClient<Http>>,
tokio_handle: tokio::runtime::Handle,
}

impl RpcProvider {
pub fn new(rpc_url: String) -> Result<Self> {
let http_client = ethers_providers::Provider::<Http>::try_from(&rpc_url)?;
let http_client =
ethers_providers::Provider::<RetryClient<Http>>::new_client(&rpc_url, 3, 500)?;
let tokio_handle = tokio::runtime::Handle::current();

Ok(RpcProvider {
Expand Down

0 comments on commit ddb349b

Please sign in to comment.