Skip to content

Commit 766180d

Browse files
authored
Merge of #5449
2 parents 65a6118 + 807c032 commit 766180d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

beacon_node/lighthouse_network/src/service/behaviour.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::types::SnappyTransform;
55

66
use crate::gossipsub;
77
use libp2p::identify;
8+
use libp2p::swarm::behaviour::toggle::Toggle;
89
use libp2p::swarm::NetworkBehaviour;
910
use libp2p::upnp::tokio::Behaviour as Upnp;
1011
use types::EthSpec;
@@ -34,7 +35,7 @@ where
3435
/// Provides IP addresses and peer information.
3536
pub identify: identify::Behaviour,
3637
/// Libp2p UPnP port mapping.
37-
pub upnp: Upnp,
38+
pub upnp: Toggle<Upnp>,
3839
/// The routing pub-sub mechanism for eth2.
3940
pub gossipsub: Gossipsub,
4041
}

beacon_node/lighthouse_network/src/service/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use api_types::{PeerRequestId, Request, RequestId, Response};
2929
use futures::stream::StreamExt;
3030
use gossipsub_scoring_parameters::{lighthouse_gossip_thresholds, PeerScoreSettings};
3131
use libp2p::multiaddr::{self, Multiaddr, Protocol as MProtocol};
32+
use libp2p::swarm::behaviour::toggle::Toggle;
3233
use libp2p::swarm::{Swarm, SwarmEvent};
3334
use libp2p::{identify, PeerId, SwarmBuilder};
3435
use slog::{crit, debug, info, o, trace, warn};
@@ -379,6 +380,11 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
379380
libp2p::connection_limits::Behaviour::new(limits)
380381
};
381382

383+
let upnp = Toggle::from(
384+
config
385+
.upnp_enabled
386+
.then_some(libp2p::upnp::tokio::Behaviour::default()),
387+
);
382388
let behaviour = {
383389
Behaviour {
384390
gossipsub,
@@ -387,7 +393,7 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
387393
identify,
388394
peer_manager,
389395
connection_limits,
390-
upnp: Default::default(),
396+
upnp,
391397
}
392398
};
393399

0 commit comments

Comments
 (0)