diff --git a/tls-utils/src/quic_client_certificate.rs b/tls-utils/src/quic_client_certificate.rs index 24eea9cbc26a13..4870e3493a7075 100644 --- a/tls-utils/src/quic_client_certificate.rs +++ b/tls-utils/src/quic_client_certificate.rs @@ -11,12 +11,12 @@ pub struct QuicClientCertificate { impl QuicClientCertificate { pub fn new(keypair: Option<&Keypair>) -> Self { - if let Some(keypair) = keypair { - let (certificate, key) = new_dummy_x509_certificate(keypair); - Self { certificate, key } + let keypair = if let Some(keypair) = keypair { + keypair } else { - let (certificate, key) = new_dummy_x509_certificate(&Keypair::new()); - Self { certificate, key } - } + &Keypair::new() + }; + let (certificate, key) = new_dummy_x509_certificate(keypair); + Self { certificate, key } } } diff --git a/tpu-client-next/src/connection_workers_scheduler.rs b/tpu-client-next/src/connection_workers_scheduler.rs index f74e7acfe0acbd..9e2f4a0f91d83e 100644 --- a/tpu-client-next/src/connection_workers_scheduler.rs +++ b/tpu-client-next/src/connection_workers_scheduler.rs @@ -70,7 +70,7 @@ pub struct ConnectionWorkersSchedulerConfig { /// Optional stake identity keypair used in the endpoint certificate for /// identifying the sender. - pub identity: Option, + pub stake_identity: Option, /// The number of connections to be maintained by the scheduler. pub num_connections: usize, @@ -101,14 +101,17 @@ impl ConnectionWorkersScheduler { /// /// Runs the main loop that handles worker scheduling and management for /// connections. Returns the error quic statistics per connection address or - /// an error. + /// an error along with receiver for transactions. The receiver returned + /// back to the user because in some cases we need to re-utilize the same + /// receiver for the new scheduler. For example, this happens when the + /// identity for the validator is updated. /// /// Importantly, if some transactions were not delivered due to network /// problems, they will not be retried when the problem is resolved. pub async fn run( ConnectionWorkersSchedulerConfig { bind, - identity, + stake_identity, num_connections, skip_check_transaction_age, worker_channel_size, @@ -119,7 +122,7 @@ impl ConnectionWorkersScheduler { mut transaction_receiver: mpsc::Receiver, cancel: CancellationToken, ) -> Result { - let endpoint = Self::setup_endpoint(bind, identity.as_ref())?; + let endpoint = Self::setup_endpoint(bind, stake_identity.as_ref())?; debug!("Client endpoint bind address: {:?}", endpoint.local_addr()); let mut workers = WorkersCache::new(num_connections, cancel.clone()); let mut send_stats_per_addr = SendTransactionStatsPerAddr::new(); @@ -195,9 +198,9 @@ impl ConnectionWorkersScheduler { /// Sets up the QUIC endpoint for the scheduler to handle connections. fn setup_endpoint( bind: SocketAddr, - identity: Option<&Keypair>, + stake_identity: Option<&Keypair>, ) -> Result { - let client_certificate = QuicClientCertificate::new(identity); + let client_certificate = QuicClientCertificate::new(stake_identity); let client_config = create_client_config(client_certificate); let endpoint = create_client_endpoint(bind, client_config)?; Ok(endpoint) diff --git a/tpu-client-next/tests/connection_workers_scheduler_test.rs b/tpu-client-next/tests/connection_workers_scheduler_test.rs index aa2c5a9b84286a..05b7ce9e050783 100644 --- a/tpu-client-next/tests/connection_workers_scheduler_test.rs +++ b/tpu-client-next/tests/connection_workers_scheduler_test.rs @@ -45,7 +45,7 @@ use { fn test_config(identity: Option) -> ConnectionWorkersSchedulerConfig { ConnectionWorkersSchedulerConfig { bind: SocketAddr::new(Ipv4Addr::new(127, 0, 0, 1).into(), 0), - identity, + stake_identity: identity, num_connections: 1, skip_check_transaction_age: false, // At the moment we have only one strategy to send transactions: we try