Skip to content

Commit acd49ec

Browse files
committed
address PR comments
1 parent f48cb9f commit acd49ec

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

tls-utils/src/quic_client_certificate.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ pub struct QuicClientCertificate {
1111

1212
impl QuicClientCertificate {
1313
pub fn new(keypair: Option<&Keypair>) -> Self {
14-
if let Some(keypair) = keypair {
15-
let (certificate, key) = new_dummy_x509_certificate(keypair);
16-
Self { certificate, key }
14+
let keypair = if let Some(keypair) = keypair {
15+
keypair
1716
} else {
18-
let (certificate, key) = new_dummy_x509_certificate(&Keypair::new());
19-
Self { certificate, key }
20-
}
17+
&Keypair::new()
18+
};
19+
let (certificate, key) = new_dummy_x509_certificate(keypair);
20+
Self { certificate, key }
2121
}
2222
}

tpu-client-next/src/connection_workers_scheduler.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub struct ConnectionWorkersSchedulerConfig {
7070

7171
/// Optional stake identity keypair used in the endpoint certificate for
7272
/// identifying the sender.
73-
pub identity: Option<Keypair>,
73+
pub stake_identity: Option<Keypair>,
7474

7575
/// The number of connections to be maintained by the scheduler.
7676
pub num_connections: usize,
@@ -101,14 +101,17 @@ impl ConnectionWorkersScheduler {
101101
///
102102
/// Runs the main loop that handles worker scheduling and management for
103103
/// connections. Returns the error quic statistics per connection address or
104-
/// an error.
104+
/// an error along with receiver for transactions. The receiver returned
105+
/// back to the user because in some cases we need to re-utilize the same
106+
/// receiver for the new scheduler. For example, this happens when the
107+
/// identity for the validator is updated.
105108
///
106109
/// Importantly, if some transactions were not delivered due to network
107110
/// problems, they will not be retried when the problem is resolved.
108111
pub async fn run(
109112
ConnectionWorkersSchedulerConfig {
110113
bind,
111-
identity,
114+
stake_identity,
112115
num_connections,
113116
skip_check_transaction_age,
114117
worker_channel_size,
@@ -119,7 +122,7 @@ impl ConnectionWorkersScheduler {
119122
mut transaction_receiver: mpsc::Receiver<TransactionBatch>,
120123
cancel: CancellationToken,
121124
) -> Result<TransactionStatsAndReceiver, ConnectionWorkersSchedulerError> {
122-
let endpoint = Self::setup_endpoint(bind, identity.as_ref())?;
125+
let endpoint = Self::setup_endpoint(bind, stake_identity.as_ref())?;
123126
debug!("Client endpoint bind address: {:?}", endpoint.local_addr());
124127
let mut workers = WorkersCache::new(num_connections, cancel.clone());
125128
let mut send_stats_per_addr = SendTransactionStatsPerAddr::new();
@@ -195,9 +198,9 @@ impl ConnectionWorkersScheduler {
195198
/// Sets up the QUIC endpoint for the scheduler to handle connections.
196199
fn setup_endpoint(
197200
bind: SocketAddr,
198-
identity: Option<&Keypair>,
201+
stake_identity: Option<&Keypair>,
199202
) -> Result<Endpoint, ConnectionWorkersSchedulerError> {
200-
let client_certificate = QuicClientCertificate::new(identity);
203+
let client_certificate = QuicClientCertificate::new(stake_identity);
201204
let client_config = create_client_config(client_certificate);
202205
let endpoint = create_client_endpoint(bind, client_config)?;
203206
Ok(endpoint)

tpu-client-next/tests/connection_workers_scheduler_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use {
4545
fn test_config(identity: Option<Keypair>) -> ConnectionWorkersSchedulerConfig {
4646
ConnectionWorkersSchedulerConfig {
4747
bind: SocketAddr::new(Ipv4Addr::new(127, 0, 0, 1).into(), 0),
48-
identity,
48+
stake_identity: identity,
4949
num_connections: 1,
5050
skip_check_transaction_age: false,
5151
// At the moment we have only one strategy to send transactions: we try

0 commit comments

Comments
 (0)