From 2a421778efa6ff75560161cf62bde2b11b7c6c47 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Thu, 12 Oct 2023 14:30:17 -0700 Subject: [PATCH] get rid of a noop future --- web3_proxy/src/rpcs/many.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/web3_proxy/src/rpcs/many.rs b/web3_proxy/src/rpcs/many.rs index af8cb3af..a3168566 100644 --- a/web3_proxy/src/rpcs/many.rs +++ b/web3_proxy/src/rpcs/many.rs @@ -349,6 +349,7 @@ impl Web3Rpcs { /// subscribe to blocks and transactions from all the backend rpcs. /// blocks are processed by all the `Web3Rpc`s and then sent to the `block_receiver` /// transaction ids from all the `Web3Rpc`s are deduplicated and forwarded to `pending_tx_sender` + /// returns True if the subscription is not needed. False if it exited after starting async fn subscribe( self: Arc, block_and_rpc_receiver: mpsc::UnboundedReceiver, @@ -374,21 +375,13 @@ impl Web3Rpcs { if futures.is_empty() { // no transaction or block subscriptions. - - // TODO: i don't like this. it's a hack to keep the tokio task alive - let handle = tokio::task::Builder::default() - .name("noop") - .spawn(async move { - futures::future::pending::<()>().await; - - Ok(()) - })?; - - futures.push(flatten_handle(handle)); + info!(?self, "no subscriptions needed"); + return Ok(()); } if let Err(e) = try_join_all(futures).await { error!(?self, "subscriptions over"); + // TODO: i think this should maybe be a panic return Err(e); }