Skip to content

Commit

Permalink
Fix config error for configuring network ports
Browse files Browse the repository at this point in the history
  • Loading branch information
iduartgomez committed Jun 9, 2024
1 parent 6d364ce commit 0d7a1dc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions crates/core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/node/network_bridge/p2p_protoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<UdpSocket>(
Expand Down
10 changes: 5 additions & 5 deletions crates/core/src/transport/rate_limiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ impl PacketRateLimiter<InstantTimeSrc> {

impl<T: TimeSource> PacketRateLimiter<T> {
pub(super) async fn rate_limiter<S: Socket>(mut self, bandwidth_limit: usize, socket: Arc<S>) {
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");
}
Expand Down Expand Up @@ -79,7 +79,7 @@ impl<T: TimeSource> PacketRateLimiter<T> {
/// 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<Duration> {
Expand Down

0 comments on commit 0d7a1dc

Please sign in to comment.