From 0d7a1dcbe7ab50aa29926254f5c7f6ffbc86e100 Mon Sep 17 00:00:00 2001 From: Ignacio Duart Date: Sun, 9 Jun 2024 18:03:10 +0200 Subject: [PATCH] Fix config error for configuring network ports --- crates/core/src/config.rs | 8 ++++---- crates/core/src/node/network_bridge/p2p_protoc.rs | 2 +- crates/core/src/transport/rate_limiter.rs | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/core/src/config.rs b/crates/core/src/config.rs index 49d987d53..99880d915 100644 --- a/crates/core/src/config.rs +++ b/crates/core/src/config.rs @@ -280,14 +280,14 @@ impl ConfigArgs { mode, peer_id, network_api: NetworkApiConfig { - address: self.ws_api.address.unwrap_or_else(|| match mode { + address: self.network_listener.address.unwrap_or_else(|| match mode { OperationMode::Local => default_local_address(), OperationMode::Network => default_address(), }), port: self - .ws_api - .ws_api_port - .unwrap_or(default_http_gateway_port()), + .network_listener + .network_port + .unwrap_or(default_network_port()), public_address: self.network_listener.public_address, public_port: self.network_listener.public_port, }, diff --git a/crates/core/src/node/network_bridge/p2p_protoc.rs b/crates/core/src/node/network_bridge/p2p_protoc.rs index e18007180..2916d5a3f 100644 --- a/crates/core/src/node/network_bridge/p2p_protoc.rs +++ b/crates/core/src/node/network_bridge/p2p_protoc.rs @@ -145,7 +145,7 @@ impl P2pConnManager { ) -> Result<(), anyhow::Error> { use ConnMngrActions::*; - tracing::info!(%self.listening_port, %self.is_gateway, key = %self.key_pair.public(), "Openning network listener"); + tracing::info!(%self.listening_port, %self.listening_ip, %self.is_gateway, key = %self.key_pair.public(), "Openning network listener"); let (mut outbound_conn_handler, mut inbound_conn_handler) = create_connection_handler::( diff --git a/crates/core/src/transport/rate_limiter.rs b/crates/core/src/transport/rate_limiter.rs index 75b2c6e39..fce9635ca 100644 --- a/crates/core/src/transport/rate_limiter.rs +++ b/crates/core/src/transport/rate_limiter.rs @@ -35,19 +35,19 @@ impl PacketRateLimiter { impl PacketRateLimiter { pub(super) async fn rate_limiter(mut self, bandwidth_limit: usize, socket: Arc) { + tracing::info!(bandwidth_limit, "Rate limiter task started"); while let Some((socket_addr, packet)) = self.outbound_packets.recv().await { if let Some(wait_time) = self.can_send_packet(bandwidth_limit, packet.len()) { tokio::time::sleep(wait_time).await; if let Err(error) = socket.send_to(&packet, socket_addr).await { tracing::debug!("Error sending packet: {:?}", error); - } else { - self.add_packet(packet.len()); + continue; } } else if let Err(error) = socket.send_to(&packet, socket_addr).await { tracing::debug!(%socket_addr, "Error sending packet: {:?}", error); - } else { - self.add_packet(packet.len()); + continue; } + self.add_packet(packet.len()); } tracing::debug!("Rate limiter task ended unexpectedly"); } @@ -79,7 +79,7 @@ impl PacketRateLimiter { /// exceeded within the `window_size`. Otherwise returns Some(wait_time) where wait_time is the /// amount of time that should be waited before sending the packet. /// - /// `bandwidth_limit` should be set to 50% higher than the target upstream bandwidth the + /// `bandwidth_limit` (in bytes) should be set to 50% higher than the target upstream bandwidth the /// [topology manager](crate::topology::TopologyManager) is aiming for, as it serves /// as a hard limit which we'd prefer not to hit. fn can_send_packet(&mut self, bandwidth_limit: usize, packet_size: usize) -> Option {