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();
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 {

View File

@ -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(

View File

@ -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<Vec<u8>>) -> 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(())
}

View File

@ -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 {