diff --git a/bench-tps/src/bench_tps_client/tpu_client.rs b/bench-tps/src/bench_tps_client/tpu_client.rs index c56da2ae6..ae762e529 100644 --- a/bench-tps/src/bench_tps_client/tpu_client.rs +++ b/bench-tps/src/bench_tps_client/tpu_client.rs @@ -1,9 +1,7 @@ use { crate::bench_tps_client::{BenchTpsClient, BenchTpsError, Result}, solana_client::tpu_client::TpuClient, - solana_connection_cache::connection_cache::{ - ConnectionManager, ConnectionPool, NewConnectionConfig, - }, + solana_connection_cache::connection_cache::{ConnectionManager, ConnectionPool}, solana_sdk::{ account::Account, commitment_config::CommitmentConfig, epoch_info::EpochInfo, hash::Hash, message::Message, pubkey::Pubkey, signature::Signature, transaction::Transaction, @@ -14,7 +12,6 @@ impl BenchTpsClient for TpuClient where P: ConnectionPool, M: ConnectionManager, - C: NewConnectionConfig, { fn send_transaction(&self, transaction: Transaction) -> Result { let signature = transaction.signatures[0]; diff --git a/client/src/connection_cache.rs b/client/src/connection_cache.rs index 44673c06f..0bce6bbb3 100644 --- a/client/src/connection_cache.rs +++ b/client/src/connection_cache.rs @@ -5,7 +5,6 @@ use { client_connection::ClientConnection, connection_cache::{ BaseClientConnection, ConnectionCache as BackendConnectionCache, ConnectionPool, - NewConnectionConfig, }, }, solana_quic_client::{QuicConfig, QuicConnectionManager, QuicPool}, diff --git a/client/src/nonblocking/tpu_client.rs b/client/src/nonblocking/tpu_client.rs index 5e71eae36..d04df3e45 100644 --- a/client/src/nonblocking/tpu_client.rs +++ b/client/src/nonblocking/tpu_client.rs @@ -3,7 +3,6 @@ use { crate::{connection_cache::ConnectionCache, tpu_client::TpuClientConfig}, solana_connection_cache::connection_cache::{ ConnectionCache as BackendConnectionCache, ConnectionManager, ConnectionPool, - NewConnectionConfig, }, solana_quic_client::{QuicConfig, QuicConnectionManager, QuicPool}, solana_rpc_client::nonblocking::rpc_client::RpcClient, @@ -31,7 +30,6 @@ impl TpuClient where P: ConnectionPool, M: ConnectionManager, - C: NewConnectionConfig, { /// Serialize and send transaction to the current and upcoming leader TPUs according to fanout /// size @@ -101,7 +99,6 @@ impl TpuClient where P: ConnectionPool, M: ConnectionManager, - C: NewConnectionConfig, { /// Create a new client that disconnects when dropped pub async fn new_with_connection_cache( diff --git a/client/src/tpu_client.rs b/client/src/tpu_client.rs index 453941513..2abba3f77 100644 --- a/client/src/tpu_client.rs +++ b/client/src/tpu_client.rs @@ -2,7 +2,6 @@ use { crate::connection_cache::ConnectionCache, solana_connection_cache::connection_cache::{ ConnectionCache as BackendConnectionCache, ConnectionManager, ConnectionPool, - NewConnectionConfig, }, solana_quic_client::{QuicConfig, QuicConnectionManager, QuicPool}, solana_rpc_client::rpc_client::RpcClient, @@ -35,7 +34,6 @@ impl TpuClient where P: ConnectionPool, M: ConnectionManager, - C: NewConnectionConfig, { /// Serialize and send transaction to the current and upcoming leader TPUs according to fanout /// size @@ -92,7 +90,6 @@ impl TpuClient where P: ConnectionPool, M: ConnectionManager, - C: NewConnectionConfig, { /// Create a new client that disconnects when dropped pub fn new_with_connection_cache( diff --git a/connection-cache/src/connection_cache.rs b/connection-cache/src/connection_cache.rs index fe1c2deda..086e6b62e 100644 --- a/connection-cache/src/connection_cache.rs +++ b/connection-cache/src/connection_cache.rs @@ -29,7 +29,7 @@ pub enum Protocol { pub trait ConnectionManager { type ConnectionPool: ConnectionPool; - type NewConnectionConfig: NewConnectionConfig; + type NewConnectionConfig; const PROTOCOL: Protocol; @@ -55,7 +55,6 @@ impl ConnectionCache where P: ConnectionPool, M: ConnectionManager, - C: NewConnectionConfig, { pub fn new( name: &'static str, @@ -300,12 +299,8 @@ pub enum ClientError { IoError(#[from] std::io::Error), } -pub trait NewConnectionConfig: Sized { - fn new() -> Result; -} - pub trait ConnectionPool { - type NewConnectionConfig: NewConnectionConfig; + type NewConnectionConfig; type BaseClientConnection: BaseClientConnection; /// Add a connection to the pool @@ -441,7 +436,7 @@ mod tests { } } - impl NewConnectionConfig for MockUdpConfig { + impl MockUdpConfig { fn new() -> Result { Ok(Self { udp_socket: Arc::new( diff --git a/quic-client/src/lib.rs b/quic-client/src/lib.rs index 0b6de9c57..062b6bc82 100644 --- a/quic-client/src/lib.rs +++ b/quic-client/src/lib.rs @@ -19,7 +19,7 @@ use { solana_connection_cache::{ connection_cache::{ BaseClientConnection, ClientError, ConnectionManager, ConnectionPool, - ConnectionPoolError, NewConnectionConfig, Protocol, + ConnectionPoolError, Protocol, }, connection_cache_stats::ConnectionCacheStats, }, @@ -89,8 +89,8 @@ pub struct QuicConfig { client_endpoint: Option, } -impl NewConnectionConfig for QuicConfig { - fn new() -> Result { +impl QuicConfig { + pub fn new() -> Result { let (cert, priv_key) = new_self_signed_tls_certificate(&Keypair::new(), IpAddr::V4(Ipv4Addr::UNSPECIFIED))?; Ok(Self { diff --git a/thin-client/src/thin_client.rs b/thin-client/src/thin_client.rs index b1ae08fd7..c61addfb5 100644 --- a/thin-client/src/thin_client.rs +++ b/thin-client/src/thin_client.rs @@ -8,9 +8,7 @@ use { rayon::iter::{IntoParallelIterator, ParallelIterator}, solana_connection_cache::{ client_connection::ClientConnection, - connection_cache::{ - ConnectionCache, ConnectionManager, ConnectionPool, NewConnectionConfig, - }, + connection_cache::{ConnectionCache, ConnectionManager, ConnectionPool}, }, solana_rpc_client::rpc_client::RpcClient, solana_rpc_client_api::{config::RpcProgramAccountsConfig, response::Response}, @@ -126,7 +124,6 @@ impl ThinClient where P: ConnectionPool, M: ConnectionManager, - C: NewConnectionConfig, { /// Create a new ThinClient that will interface with the Rpc at `rpc_addr` using TCP /// and the Tpu at `tpu_addr` over `transactions_socket` using Quic or UDP @@ -327,7 +324,6 @@ impl Client for ThinClient where P: ConnectionPool, M: ConnectionManager, - C: NewConnectionConfig, { fn tpu_addr(&self) -> String { self.tpu_addr().to_string() @@ -338,7 +334,6 @@ impl SyncClient for ThinClient where P: ConnectionPool, M: ConnectionManager, - C: NewConnectionConfig, { fn send_and_confirm_message( &self, @@ -623,7 +618,6 @@ impl AsyncClient for ThinClient where P: ConnectionPool, M: ConnectionManager, - C: NewConnectionConfig, { fn async_send_versioned_transaction( &self, diff --git a/tpu-client/src/nonblocking/tpu_client.rs b/tpu-client/src/nonblocking/tpu_client.rs index b543a6370..1c3557b2d 100644 --- a/tpu-client/src/nonblocking/tpu_client.rs +++ b/tpu-client/src/nonblocking/tpu_client.rs @@ -6,7 +6,7 @@ use { log::*, solana_connection_cache::{ connection_cache::{ - ConnectionCache, ConnectionManager, ConnectionPool, NewConnectionConfig, Protocol, + ConnectionCache, ConnectionManager, ConnectionPool, Protocol, DEFAULT_CONNECTION_POOL_SIZE, }, nonblocking::client_connection::ClientConnection, @@ -280,7 +280,6 @@ async fn send_wire_transaction_to_addr( where P: ConnectionPool, M: ConnectionManager, - C: NewConnectionConfig, { let conn = connection_cache.get_nonblocking_connection(addr); conn.send_data(&wire_transaction).await @@ -294,7 +293,6 @@ async fn send_wire_transaction_batch_to_addr( where P: ConnectionPool, M: ConnectionManager, - C: NewConnectionConfig, { let conn = connection_cache.get_nonblocking_connection(addr); conn.send_data_batch(wire_transactions).await @@ -304,7 +302,6 @@ impl TpuClient where P: ConnectionPool, M: ConnectionManager, - C: NewConnectionConfig, { /// Serialize and send transaction to the current and upcoming leader TPUs according to fanout /// size diff --git a/tpu-client/src/tpu_client.rs b/tpu-client/src/tpu_client.rs index 9d5a15968..f2e9155f3 100644 --- a/tpu-client/src/tpu_client.rs +++ b/tpu-client/src/tpu_client.rs @@ -3,7 +3,7 @@ use { crate::nonblocking::tpu_client::TpuClient as NonblockingTpuClient, rayon::iter::{IntoParallelIterator, ParallelIterator}, solana_connection_cache::connection_cache::{ - ConnectionCache, ConnectionManager, ConnectionPool, NewConnectionConfig, + ConnectionCache, ConnectionManager, ConnectionPool, }, solana_rpc_client::rpc_client::RpcClient, solana_sdk::{clock::Slot, transaction::Transaction, transport::Result as TransportResult}, @@ -71,7 +71,6 @@ impl TpuClient where P: ConnectionPool, M: ConnectionManager, - C: NewConnectionConfig, { /// Serialize and send transaction to the current and upcoming leader TPUs according to fanout /// size diff --git a/udp-client/src/lib.rs b/udp-client/src/lib.rs index 00fb093da..75ba9139d 100644 --- a/udp-client/src/lib.rs +++ b/udp-client/src/lib.rs @@ -11,7 +11,7 @@ use { solana_connection_cache::{ connection_cache::{ BaseClientConnection, ClientError, ConnectionManager, ConnectionPool, - ConnectionPoolError, NewConnectionConfig, Protocol, + ConnectionPoolError, Protocol, }, connection_cache_stats::ConnectionCacheStats, }, @@ -57,7 +57,7 @@ pub struct UdpConfig { udp_socket: Arc, } -impl NewConnectionConfig for UdpConfig { +impl UdpConfig { fn new() -> Result { let socket = solana_net_utils::bind_with_any_port(IpAddr::V4(Ipv4Addr::UNSPECIFIED)) .map_err(Into::::into)?;