From 82ee98a21ad61655d3de9f18976121fb60e8c4b2 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 10 Oct 2023 15:28:47 +0700 Subject: [PATCH] networking: Refactor the code. - add comments --- crates/subspace-networking/src/constructor.rs | 4 +++- crates/subspace-networking/src/node_runner.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/subspace-networking/src/constructor.rs b/crates/subspace-networking/src/constructor.rs index e14b4f93c1..41ae0fe7f1 100644 --- a/crates/subspace-networking/src/constructor.rs +++ b/crates/subspace-networking/src/constructor.rs @@ -235,7 +235,9 @@ pub struct Config { pub special_target_connections: u32, /// Addresses to bootstrap Kademlia network pub bootstrap_addresses: Vec, - /// Kademlia mode. + /// Kademlia mode. The default value is set to Static(Client). The peer won't add its address + /// to other peers` Kademlia routing table. Changing this behaviour implies that a peer can + /// provide pieces to others. pub kademlia_mode: KademliaMode, /// Known external addresses to the local peer. The addresses will be added on the swarm start /// and enable peer to notify others about its reachable address. diff --git a/crates/subspace-networking/src/node_runner.rs b/crates/subspace-networking/src/node_runner.rs index b5cd35a56f..59e56a1e77 100644 --- a/crates/subspace-networking/src/node_runner.rs +++ b/crates/subspace-networking/src/node_runner.rs @@ -1195,7 +1195,7 @@ where if let AutonatEvent::StatusChanged { old, new } = event { info!(?old, ?new, "Public address status changed."); - if let KademliaMode::Dynamic { .. } = self.kademlia_mode { + if matches!(self.kademlia_mode, KademliaMode::Dynamic { .. }) { let mode = match &new { NatStatus::Public(address) => { if is_global_address_or_dns(address)