From 1a93e39b095295aff8b8e2757876d90bcad46b40 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Thu, 9 Feb 2023 11:56:07 -0800 Subject: [PATCH] FuturesUnordered on the spawn handles --- web3_proxy/src/rpcs/many.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web3_proxy/src/rpcs/many.rs b/web3_proxy/src/rpcs/many.rs index 1af2cf44..a46e66f6 100644 --- a/web3_proxy/src/rpcs/many.rs +++ b/web3_proxy/src/rpcs/many.rs @@ -12,7 +12,7 @@ use crate::rpcs::transactions::TxStatus; use counter::Counter; use derive_more::From; use ethers::prelude::{ProviderError, TxHash, H256, U64}; -use futures::future::{join_all, try_join_all}; +use futures::future::try_join_all; use futures::stream::FuturesUnordered; use futures::StreamExt; use hashbrown::{HashMap, HashSet}; @@ -124,7 +124,7 @@ impl Web3Rpcs { // turn configs into connections (in parallel) // TODO: move this into a helper function. then we can use it when configs change (will need a remove function too) - let mut spawn_handles: Vec<_> = server_configs + let mut spawn_handles: FuturesUnordered<_> = server_configs .into_iter() .filter_map(|(server_name, server_config)| { if server_config.disabled { @@ -173,7 +173,7 @@ impl Web3Rpcs { let mut handles = vec![]; // TODO: futures unordered? - for x in join_all(spawn_handles).await { + while let Some(x) = spawn_handles.next().await { match x { Ok(Ok((connection, handle))) => { // web3 connection worked