aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport/libp2p.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/libp2p.rs')
-rw-r--r--src/transport/libp2p.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/transport/libp2p.rs b/src/transport/libp2p.rs
index c67f681..b53a4c3 100644
--- a/src/transport/libp2p.rs
+++ b/src/transport/libp2p.rs
@@ -90,6 +90,13 @@ const MAX_MESSAGE: usize = 128 << 20;
const CONNECT_TIMEOUT: Duration = Duration::from_secs(10);
/// A connection nobody uses is closed after this; neighbours keep theirs busy.
const IDLE_TIMEOUT: Duration = Duration::from_secs(300);
+/// Addresses of one dial tried at once (libp2p's default: 8). Hole punching (`HolePunching`)
+/// dials every address both sides offer, where they listen (LAN, VPNs, public IPv6) and
+/// where others saw them, often more than 8, while the other side punches towards all of
+/// them at the same moment: an address dialled only after others failed (each after
+/// QUIC's 5 s handshake timeout) misses its punch, and the LAN's is often among the
+/// last. Dials of the member list's addresses (`ADDRESSES_PER_PEER`) are unchanged.
+const DIAL_CONCURRENCY: std::num::NonZeroU8 = std::num::NonZeroU8::new(32).unwrap();
/// How long a stream may take to open and to carry a message, before what its size adds
/// (`stream_timeout`).
const STREAM_TIMEOUT: Duration = Duration::from_secs(10);
@@ -1205,7 +1212,9 @@ fn network_swarm(key: Keypair, features: Features) -> Result<Swarm<Behaviour>> {
/// (`Libp2pConfig::public`), whose nodes speak only some: there a protocol they don't
/// would fail late, and unclearly.
fn swarm_config(config: ::libp2p::swarm::Config, features: Features) -> ::libp2p::swarm::Config {
- let config = config.with_idle_connection_timeout(IDLE_TIMEOUT);
+ let config = config
+ .with_idle_connection_timeout(IDLE_TIMEOUT)
+ .with_dial_concurrency_factor(DIAL_CONCURRENCY);
if features.public {
config
} else {