Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillLykov committed Jan 15, 2025
1 parent f48cb9f commit acd49ec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
12 changes: 6 additions & 6 deletions tls-utils/src/quic_client_certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
15 changes: 9 additions & 6 deletions tpu-client-next/src/connection_workers_scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub struct ConnectionWorkersSchedulerConfig {

/// Optional stake identity keypair used in the endpoint certificate for
/// identifying the sender.
pub identity: Option<Keypair>,
pub stake_identity: Option<Keypair>,

/// The number of connections to be maintained by the scheduler.
pub num_connections: usize,
Expand Down Expand Up @@ -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,
Expand All @@ -119,7 +122,7 @@ impl ConnectionWorkersScheduler {
mut transaction_receiver: mpsc::Receiver<TransactionBatch>,
cancel: CancellationToken,
) -> Result<TransactionStatsAndReceiver, ConnectionWorkersSchedulerError> {
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();
Expand Down Expand Up @@ -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<Endpoint, ConnectionWorkersSchedulerError> {
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)
Expand Down
2 changes: 1 addition & 1 deletion tpu-client-next/tests/connection_workers_scheduler_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use {
fn test_config(identity: Option<Keypair>) -> 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
Expand Down

0 comments on commit acd49ec

Please sign in to comment.