Skip to content

Commit

Permalink
feat(networking): QUIC receive window override env
Browse files Browse the repository at this point in the history
Allow to pass ANT_MAX_STREAM_DATA=x to override the stream receive
window setting in libp2p/quinn.
  • Loading branch information
b-zee committed Jan 7, 2025
1 parent 246638f commit 690ca60
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion ant-networking/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use libp2p::{
PeerId, Transport as _,
};

const MAX_STREAM_DATA_ENV_STR: &str = "ANT_MAX_STREAM_DATA";

pub(crate) fn build_transport(
keypair: &Keypair,
#[cfg(feature = "open-metrics")] registries: &mut MetricsRegistries,
Expand All @@ -30,5 +32,18 @@ pub(crate) fn build_transport(
fn generate_quic_transport(
keypair: &Keypair,
) -> libp2p::quic::GenTransport<libp2p::quic::tokio::Provider> {
libp2p::quic::tokio::Transport::new(libp2p::quic::Config::new(keypair))
let mut quic_config = libp2p::quic::Config::new(keypair);
if let Ok(val) = std::env::var(MAX_STREAM_DATA_ENV_STR) {
match val.parse::<u32>() {
Ok(val) => {
quic_config.max_stream_data = val;
tracing::info!("Overriding QUIC connection receive window value to {val}");
}
Err(e) => {
tracing::warn!("QUIC connection receive window value override failed. Could not parse `{MAX_STREAM_DATA_ENV_STR}={val}` as integer: {e}")
}
}
}

libp2p::quic::tokio::Transport::new(quic_config)
}

0 comments on commit 690ca60

Please sign in to comment.