mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 08:52:54 +00:00
limit dial concurrency on Swarm (#6184)
* limit dial concurrency on Swarm * Merge branch 'unstable' into set-dial-concurrency
This commit is contained in:
@@ -33,6 +33,7 @@ use libp2p::swarm::behaviour::toggle::Toggle;
|
|||||||
use libp2p::swarm::{Swarm, SwarmEvent};
|
use libp2p::swarm::{Swarm, SwarmEvent};
|
||||||
use libp2p::{identify, PeerId, SwarmBuilder};
|
use libp2p::{identify, PeerId, SwarmBuilder};
|
||||||
use slog::{crit, debug, info, o, trace, warn};
|
use slog::{crit, debug, info, o, trace, warn};
|
||||||
|
use std::num::{NonZeroU8, NonZeroUsize};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::{
|
use std::{
|
||||||
@@ -415,6 +416,11 @@ impl<E: EthSpec> Network<E> {
|
|||||||
// sets up the libp2p swarm.
|
// sets up the libp2p swarm.
|
||||||
|
|
||||||
let swarm = {
|
let swarm = {
|
||||||
|
let config = libp2p::swarm::Config::with_executor(Executor(executor))
|
||||||
|
.with_notify_handler_buffer_size(NonZeroUsize::new(7).expect("Not zero"))
|
||||||
|
.with_per_connection_event_buffer_size(4)
|
||||||
|
.with_dial_concurrency_factor(NonZeroU8::new(1).unwrap());
|
||||||
|
|
||||||
let builder = SwarmBuilder::with_existing_identity(local_keypair)
|
let builder = SwarmBuilder::with_existing_identity(local_keypair)
|
||||||
.with_tokio()
|
.with_tokio()
|
||||||
.with_other_transport(|_key| transport)
|
.with_other_transport(|_key| transport)
|
||||||
@@ -426,25 +432,13 @@ impl<E: EthSpec> Network<E> {
|
|||||||
.with_bandwidth_metrics(libp2p_registry)
|
.with_bandwidth_metrics(libp2p_registry)
|
||||||
.with_behaviour(|_| behaviour)
|
.with_behaviour(|_| behaviour)
|
||||||
.expect("infalible")
|
.expect("infalible")
|
||||||
.with_swarm_config(|_| {
|
.with_swarm_config(|_| config)
|
||||||
libp2p::swarm::Config::with_executor(Executor(executor))
|
|
||||||
.with_notify_handler_buffer_size(
|
|
||||||
std::num::NonZeroUsize::new(7).expect("Not zero"),
|
|
||||||
)
|
|
||||||
.with_per_connection_event_buffer_size(4)
|
|
||||||
})
|
|
||||||
.build()
|
.build()
|
||||||
} else {
|
} else {
|
||||||
builder
|
builder
|
||||||
.with_behaviour(|_| behaviour)
|
.with_behaviour(|_| behaviour)
|
||||||
.expect("infalible")
|
.expect("infalible")
|
||||||
.with_swarm_config(|_| {
|
.with_swarm_config(|_| config)
|
||||||
libp2p::swarm::Config::with_executor(Executor(executor))
|
|
||||||
.with_notify_handler_buffer_size(
|
|
||||||
std::num::NonZeroUsize::new(7).expect("Not zero"),
|
|
||||||
)
|
|
||||||
.with_per_connection_event_buffer_size(4)
|
|
||||||
})
|
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user