feat(autonat): remove explicit setting of server mode (#2424)

This commit is contained in:
Petar Radovic
2026-03-27 17:18:08 +01:00
committed by GitHub
parent 3fbe0c890c
commit 5b35ea0dc0
2 changed files with 5 additions and 6 deletions
+2 -6
View File
@@ -6,9 +6,7 @@
use std::error::Error;
use lb_cryptarchia_sync::ChainSyncError;
use libp2p::{
PeerId, StreamProtocol, autonat, identify, identity, kad, kad::Mode, swarm::NetworkBehaviour,
};
use libp2p::{PeerId, StreamProtocol, autonat, identify, identity, kad, swarm::NetworkBehaviour};
use rand::RngCore;
use thiserror::Error;
@@ -84,13 +82,11 @@ impl<Rng: Clone + Send + RngCore + 'static> Behaviour<Rng> {
identify_config.to_libp2p_config(public_key, &identify_protocol_name),
);
let mut kademlia = kad::Behaviour::with_config(
let kademlia = kad::Behaviour::with_config(
peer_id,
kad::store::MemoryStore::new(peer_id),
kademlia_config.to_libp2p_config(kad_protocol_name),
);
// set kademlia to server mode
kademlia.set_mode(Some(Mode::Server));
let autonat_server = autonat::v2::server::Behaviour::new(rng.clone());
let nat = nat::Behaviour::new(rng, &nat_config);
@@ -93,6 +93,9 @@ impl<R: Clone + Send + RngCore + 'static> SwarmHandler<R> {
} => {
log_routing_update(peer, &addresses.into_vec(), old_peer, is_new_peer);
}
kad::Event::ModeChanged { new_mode } => {
tracing::info!("Kademlia mode changed to {new_mode:?}");
}
event => {
tracing::debug!("Kademlia event: {:?}", event);
}