Skip to content

Commit 9554b93

Browse files
committed
QUIC-based LibP2p Swarm (replacing TCP)
1 parent 1822e31 commit 9554b93

2 files changed

Lines changed: 2 additions & 13 deletions

File tree

coordinator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ env_logger = { version = "0.10", default-features = false, features = ["humantim
5050

5151
futures = { version = "0.3", default-features = false, features = ["std"] }
5252
tokio = { version = "1", default-features = false, features = ["rt-multi-thread", "sync", "time", "macros"] }
53-
libp2p = { version = "0.52", default-features = false, features = ["tokio", "tcp", "noise", "yamux", "gossipsub", "mdns", "macros"] }
53+
libp2p = { version = "0.52", default-features = false, features = ["tokio", "quic", "gossipsub", "mdns", "macros"] }
5454

5555
[dev-dependencies]
5656
futures = { version = "0.3", default-features = false, features = ["std"] }

coordinator/src/p2p.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ use libp2p::{
2222
futures::StreamExt,
2323
identity::Keypair,
2424
PeerId,
25-
tcp::Config as TcpConfig,
26-
noise, yamux,
2725
gossipsub::{
2826
IdentTopic, FastMessageId, MessageId, MessageAuthenticity, ValidationMode, ConfigBuilder,
2927
IdentityTransform, AllowAllSubscriptionFilter, Event as GsEvent, PublishError,
@@ -276,16 +274,7 @@ impl LibP2p {
276274
// TODO: Relay client?
277275
let mut swarm = SwarmBuilder::with_existing_identity(throwaway_key_pair)
278276
.with_tokio()
279-
.with_tcp(TcpConfig::default().nodelay(true), noise::Config::new, || {
280-
let mut config = yamux::Config::default();
281-
// 1 MiB default + max message size
282-
config.set_max_buffer_size((1024 * 1024) + MAX_LIBP2P_MESSAGE_SIZE);
283-
// 256 KiB default + max message size
284-
config
285-
.set_receive_window_size(((256 * 1024) + MAX_LIBP2P_MESSAGE_SIZE).try_into().unwrap());
286-
config
287-
})
288-
.unwrap()
277+
.with_quic()
289278
.with_behaviour(|_| behavior)
290279
.unwrap()
291280
.build();

0 commit comments

Comments
 (0)