From 0ad8ac9520f7d27ccfa86f5feb5fc9a41d9d10bf Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Tue, 21 Nov 2023 02:05:48 -0500 Subject: [PATCH] QUIC-based LibP2p Swarm (replacing TCP) --- coordinator/Cargo.toml | 2 +- coordinator/src/p2p.rs | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/coordinator/Cargo.toml b/coordinator/Cargo.toml index 460e5d8b..58b94e29 100644 --- a/coordinator/Cargo.toml +++ b/coordinator/Cargo.toml @@ -48,7 +48,7 @@ env_logger = { version = "0.10", default-features = false, features = ["humantim futures = { version = "0.3", default-features = false, features = ["std"] } tokio = { version = "1", default-features = false, features = ["rt-multi-thread", "sync", "time", "macros"] } -libp2p = { version = "0.52", default-features = false, features = ["tokio", "tcp", "noise", "yamux", "gossipsub", "mdns", "macros"] } +libp2p = { version = "0.52", default-features = false, features = ["tokio", "quic", "gossipsub", "mdns", "macros"] } [dev-dependencies] futures = { version = "0.3", default-features = false, features = ["std"] } diff --git a/coordinator/src/p2p.rs b/coordinator/src/p2p.rs index aa392c52..62e54109 100644 --- a/coordinator/src/p2p.rs +++ b/coordinator/src/p2p.rs @@ -22,8 +22,6 @@ use libp2p::{ futures::StreamExt, identity::Keypair, PeerId, - tcp::Config as TcpConfig, - noise, yamux, gossipsub::{ IdentTopic, FastMessageId, MessageId, MessageAuthenticity, ValidationMode, ConfigBuilder, IdentityTransform, AllowAllSubscriptionFilter, Event as GsEvent, PublishError, @@ -276,16 +274,7 @@ impl LibP2p { // TODO: Relay client? let mut swarm = SwarmBuilder::with_existing_identity(throwaway_key_pair) .with_tokio() - .with_tcp(TcpConfig::default().nodelay(true), noise::Config::new, || { - let mut config = yamux::Config::default(); - // 1 MiB default + max message size - config.set_max_buffer_size((1024 * 1024) + MAX_LIBP2P_MESSAGE_SIZE); - // 256 KiB default + max message size - config - .set_receive_window_size(((256 * 1024) + MAX_LIBP2P_MESSAGE_SIZE).try_into().unwrap()); - config - }) - .unwrap() + .with_quic() .with_behaviour(|_| behavior) .unwrap() .build();