From 39ec405491ae504a22f338a152744704de8fc9e4 Mon Sep 17 00:00:00 2001 From: GroovieGermanikus Date: Thu, 28 Sep 2023 09:30:02 +0200 Subject: [PATCH] remove DataCache --- quic-forward-proxy/src/outbound/mod.rs | 1 - quic-forward-proxy/src/outbound/ng_forward.rs | 16 +++------- quic-forward-proxy/src/outbound/sharder.rs | 32 ------------------- .../src/outbound/tpu_connection_manager.rs | 5 --- 4 files changed, 5 insertions(+), 49 deletions(-) delete mode 100644 quic-forward-proxy/src/outbound/sharder.rs diff --git a/quic-forward-proxy/src/outbound/mod.rs b/quic-forward-proxy/src/outbound/mod.rs index 71e9ad56..cf9f4d1c 100644 --- a/quic-forward-proxy/src/outbound/mod.rs +++ b/quic-forward-proxy/src/outbound/mod.rs @@ -1,4 +1,3 @@ mod debouncer; -mod sharder; pub mod ng_forward; mod tpu_connection_manager; diff --git a/quic-forward-proxy/src/outbound/ng_forward.rs b/quic-forward-proxy/src/outbound/ng_forward.rs index 007399df..5d96f244 100644 --- a/quic-forward-proxy/src/outbound/ng_forward.rs +++ b/quic-forward-proxy/src/outbound/ng_forward.rs @@ -11,7 +11,6 @@ use log::info; use solana_sdk::pubkey::Pubkey; use tokio::sync::mpsc::Receiver; use solana_lite_rpc_core::quic_connection_utils::QuicConnectionParameters; -use solana_lite_rpc_core::stores::data_cache::DataCache; use solana_lite_rpc_core::structures::identity_stakes::IdentityStakesData; use crate::outbound::tpu_connection_manager::{TpuConnectionManager}; use crate::proxy_request_format::TpuForwardingRequest; @@ -58,10 +57,13 @@ pub async fn ng_forwarder( total_stakes: 100, }; - + let max_uni_stream_connections = compute_max_allowed_uni_streams( + identity_stakes.peer_type, + identity_stakes.stakes, + identity_stakes.total_stakes, + ); loop { - info!("tick2"); if exit_signal.load(Ordering::Relaxed) { bail!("exit signal received"); } @@ -74,21 +76,13 @@ pub async fn ng_forwarder( let mut requested_connections: HashMap = HashMap::new(); for tpu_node in forward_packet.get_tpu_nodes() { - // TODO optimize move into tpu_connection_manager and implement shutdown based on not used requested_connections.insert(tpu_node.identity_tpunode, tpu_node.tpu_socket_addr); } - let max_uni_stream_connections = compute_max_allowed_uni_streams( - identity_stakes.peer_type, - identity_stakes.stakes, - identity_stakes.total_stakes, - ); - tpu_connection_manager .update_connections( &requested_connections, max_uni_stream_connections, - DataCache::new_for_tests(), QUIC_CONNECTION_PARAMS, // TODO improve ) .await; diff --git a/quic-forward-proxy/src/outbound/sharder.rs b/quic-forward-proxy/src/outbound/sharder.rs deleted file mode 100644 index fa55d8c6..00000000 --- a/quic-forward-proxy/src/outbound/sharder.rs +++ /dev/null @@ -1,32 +0,0 @@ -pub struct Sharder { - n_shards: u32, - pos: u32, -} - -impl Sharder { - pub fn new(pos: u32, n_shards: u32) -> Self { - assert!(n_shards > 0); - assert!(pos < n_shards, "out of range"); - - Self { n_shards, pos } - } - - pub fn matching(&self, hash: u64) -> bool { - (hash % self.n_shards as u64) as u32 == self.pos - } -} - -#[cfg(test)] -mod tests { - use crate::outbound::sharder::Sharder; - - #[test] - fn shard() { - let sharder = Sharder::new(3, 10); - - assert!(sharder.matching(13)); - assert!(sharder.matching(23)); - assert!(sharder.matching(33)); - assert!(!sharder.matching(31)); - } -} diff --git a/quic-forward-proxy/src/outbound/tpu_connection_manager.rs b/quic-forward-proxy/src/outbound/tpu_connection_manager.rs index 41cf69ed..94138d2e 100644 --- a/quic-forward-proxy/src/outbound/tpu_connection_manager.rs +++ b/quic-forward-proxy/src/outbound/tpu_connection_manager.rs @@ -58,7 +58,6 @@ struct ActiveConnection { identity: Pubkey, tpu_address: SocketAddr, exit_signal: Arc, - data_cache: DataCache, connection_parameters: QuicConnectionParameters, last_used: Arc, } @@ -68,7 +67,6 @@ impl ActiveConnection { endpoints: RotatingQueue, tpu_address: SocketAddr, identity: Pubkey, - data_cache: DataCache, connection_parameters: QuicConnectionParameters, ) -> Self { Self { @@ -76,7 +74,6 @@ impl ActiveConnection { tpu_address, identity, exit_signal: Arc::new(AtomicBool::new(false)), - data_cache, connection_parameters, last_used: Arc::new(AtomicTiming::default()), } @@ -228,7 +225,6 @@ impl TpuConnectionManager { &self, requested_connections: &HashMap, max_uni_stream_connections: usize, - data_cache: DataCache, connection_parameters: QuicConnectionParameters, ) { NB_CONNECTIONS_TO_KEEP.set(requested_connections.len() as i64); @@ -241,7 +237,6 @@ impl TpuConnectionManager { self.endpoints.clone(), *tpu_addr, *tpu_identity, - data_cache.clone(), connection_parameters, );