clippy: Removes redundant async blocks (#31526)

This commit is contained in:
Brooks 2023-05-09 09:35:38 -04:00 committed by GitHub
parent a674ffc9bd
commit 6e342ded42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 54 deletions

View File

@ -241,25 +241,22 @@ impl EtcdTowerStorage {
.unwrap(); .unwrap();
let client = runtime let client = runtime
.block_on(async { .block_on(etcd_client::Client::connect(
etcd_client::Client::connect( endpoints,
endpoints, tls_config.map(|tls_config| {
tls_config.map(|tls_config| { etcd_client::ConnectOptions::default().with_tls(
etcd_client::ConnectOptions::default().with_tls( etcd_client::TlsOptions::new()
etcd_client::TlsOptions::new() .domain_name(tls_config.domain_name)
.domain_name(tls_config.domain_name) .ca_certificate(etcd_client::Certificate::from_pem(
.ca_certificate(etcd_client::Certificate::from_pem( tls_config.ca_certificate,
tls_config.ca_certificate, ))
)) .identity(etcd_client::Identity::from_pem(
.identity(etcd_client::Identity::from_pem( tls_config.identity_certificate,
tls_config.identity_certificate, tls_config.identity_private_key,
tls_config.identity_private_key, )),
)), )
) }),
}), ))
)
.await
})
.map_err(Self::etdc_to_tower_error)?; .map_err(Self::etdc_to_tower_error)?;
Ok(Self { Ok(Self {

View File

@ -36,21 +36,17 @@ fn simulate_fuzz() {
processor!(process_instruction), processor!(process_instruction),
); );
let (mut banks_client, payer, last_blockhash) = let (mut banks_client, payer, last_blockhash) = rt.block_on(program_test.start());
rt.block_on(async { program_test.start().await });
// the honggfuzz `fuzz!` macro does not allow for async closures, // the honggfuzz `fuzz!` macro does not allow for async closures,
// so we have to use the runtime directly to run async functions // so we have to use the runtime directly to run async functions
rt.block_on(async { rt.block_on(run_fuzz_instructions(
run_fuzz_instructions( &[1, 2, 3, 4, 5],
&[1, 2, 3, 4, 5], &mut banks_client,
&mut banks_client, &payer,
&payer, last_blockhash,
last_blockhash, &program_id,
&program_id, ));
)
.await
});
} }
#[test] #[test]
@ -64,20 +60,17 @@ fn simulate_fuzz_with_context() {
processor!(process_instruction), 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, // the honggfuzz `fuzz!` macro does not allow for async closures,
// so we have to use the runtime directly to run async functions // so we have to use the runtime directly to run async functions
rt.block_on(async { rt.block_on(run_fuzz_instructions(
run_fuzz_instructions( &[1, 2, 3, 4, 5],
&[1, 2, 3, 4, 5], &mut context.banks_client,
&mut context.banks_client, &context.payer,
&context.payer, context.last_blockhash,
context.last_blockhash, &program_id,
&program_id, ));
)
.await
});
} }
async fn run_fuzz_instructions( async fn run_fuzz_instructions(

View File

@ -161,14 +161,14 @@ impl ClientConnection for QuicClientConnection {
let _lock = ASYNC_TASK_SEMAPHORE.acquire(); let _lock = ASYNC_TASK_SEMAPHORE.acquire();
let inner = self.inner.clone(); 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(()) Ok(())
} }
fn send_data_batch_async(&self, buffers: Vec<Vec<u8>>) -> TransportResult<()> { fn send_data_batch_async(&self, buffers: Vec<Vec<u8>>) -> TransportResult<()> {
let _lock = ASYNC_TASK_SEMAPHORE.acquire(); let _lock = ASYNC_TASK_SEMAPHORE.acquire();
let inner = self.inner.clone(); 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(()) Ok(())
} }

View File

@ -614,16 +614,13 @@ impl LeaderTpuService {
let t_leader_tpu_service = Some({ let t_leader_tpu_service = Some({
let recent_slots = recent_slots.clone(); let recent_slots = recent_slots.clone();
let leader_tpu_cache = leader_tpu_cache.clone(); let leader_tpu_cache = leader_tpu_cache.clone();
tokio::spawn(async move { tokio::spawn(Self::run(
Self::run( rpc_client,
rpc_client, recent_slots,
recent_slots, leader_tpu_cache,
leader_tpu_cache, pubsub_client,
pubsub_client, exit,
exit, ))
)
.await
})
}); });
Ok(LeaderTpuService { Ok(LeaderTpuService {