From 6e342ded42517d383b88f1397afe7689e2a8c017 Mon Sep 17 00:00:00 2001 From: Brooks Date: Tue, 9 May 2023 09:35:38 -0400 Subject: [PATCH] clippy: Removes redundant async blocks (#31526) --- core/src/tower_storage.rs | 35 ++++++++++----------- program-test/tests/fuzz.rs | 39 ++++++++++-------------- quic-client/src/quic_client.rs | 4 +-- tpu-client/src/nonblocking/tpu_client.rs | 17 +++++------ 4 files changed, 41 insertions(+), 54 deletions(-) diff --git a/core/src/tower_storage.rs b/core/src/tower_storage.rs index 353f11137..218e1b0b3 100644 --- a/core/src/tower_storage.rs +++ b/core/src/tower_storage.rs @@ -241,25 +241,22 @@ impl EtcdTowerStorage { .unwrap(); let client = runtime - .block_on(async { - etcd_client::Client::connect( - endpoints, - tls_config.map(|tls_config| { - etcd_client::ConnectOptions::default().with_tls( - etcd_client::TlsOptions::new() - .domain_name(tls_config.domain_name) - .ca_certificate(etcd_client::Certificate::from_pem( - tls_config.ca_certificate, - )) - .identity(etcd_client::Identity::from_pem( - tls_config.identity_certificate, - tls_config.identity_private_key, - )), - ) - }), - ) - .await - }) + .block_on(etcd_client::Client::connect( + endpoints, + tls_config.map(|tls_config| { + etcd_client::ConnectOptions::default().with_tls( + etcd_client::TlsOptions::new() + .domain_name(tls_config.domain_name) + .ca_certificate(etcd_client::Certificate::from_pem( + tls_config.ca_certificate, + )) + .identity(etcd_client::Identity::from_pem( + tls_config.identity_certificate, + tls_config.identity_private_key, + )), + ) + }), + )) .map_err(Self::etdc_to_tower_error)?; Ok(Self { diff --git a/program-test/tests/fuzz.rs b/program-test/tests/fuzz.rs index 83bb603cc..751fc1894 100644 --- a/program-test/tests/fuzz.rs +++ b/program-test/tests/fuzz.rs @@ -36,21 +36,17 @@ fn simulate_fuzz() { processor!(process_instruction), ); - let (mut banks_client, payer, last_blockhash) = - rt.block_on(async { program_test.start().await }); + let (mut banks_client, payer, last_blockhash) = rt.block_on(program_test.start()); // the honggfuzz `fuzz!` macro does not allow for async closures, // so we have to use the runtime directly to run async functions - rt.block_on(async { - run_fuzz_instructions( - &[1, 2, 3, 4, 5], - &mut banks_client, - &payer, - last_blockhash, - &program_id, - ) - .await - }); + rt.block_on(run_fuzz_instructions( + &[1, 2, 3, 4, 5], + &mut banks_client, + &payer, + last_blockhash, + &program_id, + )); } #[test] @@ -64,20 +60,17 @@ fn simulate_fuzz_with_context() { processor!(process_instruction), ); - let mut context = rt.block_on(async { program_test.start_with_context().await }); + let mut context = rt.block_on(program_test.start_with_context()); // the honggfuzz `fuzz!` macro does not allow for async closures, // so we have to use the runtime directly to run async functions - rt.block_on(async { - run_fuzz_instructions( - &[1, 2, 3, 4, 5], - &mut context.banks_client, - &context.payer, - context.last_blockhash, - &program_id, - ) - .await - }); + rt.block_on(run_fuzz_instructions( + &[1, 2, 3, 4, 5], + &mut context.banks_client, + &context.payer, + context.last_blockhash, + &program_id, + )); } async fn run_fuzz_instructions( diff --git a/quic-client/src/quic_client.rs b/quic-client/src/quic_client.rs index 1ef85e83f..c2a8e862b 100644 --- a/quic-client/src/quic_client.rs +++ b/quic-client/src/quic_client.rs @@ -161,14 +161,14 @@ impl ClientConnection for QuicClientConnection { let _lock = ASYNC_TASK_SEMAPHORE.acquire(); let inner = self.inner.clone(); - let _handle = RUNTIME.spawn(async move { send_data_async(inner, data).await }); + let _handle = RUNTIME.spawn(send_data_async(inner, data)); Ok(()) } fn send_data_batch_async(&self, buffers: Vec>) -> TransportResult<()> { let _lock = ASYNC_TASK_SEMAPHORE.acquire(); let inner = self.inner.clone(); - let _handle = RUNTIME.spawn(async move { send_data_batch_async(inner, buffers).await }); + let _handle = RUNTIME.spawn(send_data_batch_async(inner, buffers)); Ok(()) } diff --git a/tpu-client/src/nonblocking/tpu_client.rs b/tpu-client/src/nonblocking/tpu_client.rs index d23de8752..9967553de 100644 --- a/tpu-client/src/nonblocking/tpu_client.rs +++ b/tpu-client/src/nonblocking/tpu_client.rs @@ -614,16 +614,13 @@ impl LeaderTpuService { let t_leader_tpu_service = Some({ let recent_slots = recent_slots.clone(); let leader_tpu_cache = leader_tpu_cache.clone(); - tokio::spawn(async move { - Self::run( - rpc_client, - recent_slots, - leader_tpu_cache, - pubsub_client, - exit, - ) - .await - }) + tokio::spawn(Self::run( + rpc_client, + recent_slots, + leader_tpu_cache, + pubsub_client, + exit, + )) }); Ok(LeaderTpuService {