allow connections to fail
This commit is contained in:
parent
b79a050fd4
commit
97b4e9f800
@ -95,6 +95,7 @@ impl Web3Connection {
|
||||
.interval(Duration::from_secs(1))
|
||||
.into()
|
||||
} else if url_str.starts_with("ws") {
|
||||
// TODO: wrapper automatically reconnect
|
||||
let provider = ethers::providers::Ws::connect(url_str.clone()).await?;
|
||||
|
||||
// TODO: make sure this automatically reconnects
|
||||
@ -142,6 +143,7 @@ impl Web3Connection {
|
||||
|
||||
loop {
|
||||
// wait for the interval
|
||||
// TODO: if error or rate limit, increase interval?
|
||||
interval.tick().await;
|
||||
|
||||
let block_number = provider.get_block_number().await.map(|x| x.as_u64())?;
|
||||
|
@ -69,11 +69,14 @@ impl Web3Connections {
|
||||
let num_connections = servers.len();
|
||||
|
||||
for server_config in servers.into_iter() {
|
||||
let connection = server_config.try_build(clock, http_client.clone()).await?;
|
||||
|
||||
connections.push(connection);
|
||||
match server_config.try_build(clock, http_client.clone()).await {
|
||||
Ok(connection) => connections.push(connection),
|
||||
Err(e) => warn!("Unable to connect to a server! {}", e),
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: exit if no connections?
|
||||
|
||||
let connections = Arc::new(Self {
|
||||
inner: connections,
|
||||
synced_connections: ArcSwap::new(Arc::new(SyncedConnections::new(num_connections))),
|
||||
|
@ -67,6 +67,7 @@ impl Web3ProxyApp {
|
||||
.user_agent(APP_USER_AGENT)
|
||||
.build()?;
|
||||
|
||||
// TODO: attach context to this error?
|
||||
let balanced_rpc_tiers =
|
||||
future::join_all(balanced_rpc_tiers.into_iter().map(|balanced_rpc_tier| {
|
||||
Web3Connections::try_new(balanced_rpc_tier, Some(http_client.clone()), &clock)
|
||||
@ -75,6 +76,7 @@ impl Web3ProxyApp {
|
||||
.into_iter()
|
||||
.collect::<anyhow::Result<Vec<Arc<Web3Connections>>>>()?;
|
||||
|
||||
// TODO: attach context to this error?
|
||||
let private_rpcs = if private_rpcs.is_empty() {
|
||||
warn!("No private relays configured. Any transactions will be broadcast to the public mempool!");
|
||||
// TODO: instead of None, set it to a list of all the rpcs from balanced_rpc_tiers. that way we broadcast very loudly
|
||||
|
Loading…
Reference in New Issue
Block a user