Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable RPC retries #42

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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