diff --git a/crates/subspace-networking/src/node.rs b/crates/subspace-networking/src/node.rs index c3bced8c7d..6e038170fa 100644 --- a/crates/subspace-networking/src/node.rs +++ b/crates/subspace-networking/src/node.rs @@ -400,15 +400,21 @@ impl Node { &self, key: Multihash, ) -> Result, GetClosestPeersError> { - self.get_closest_peers_internal(key).await + self.get_closest_peers_internal(key, true).await } /// Get closest peers by multihash key using Kademlia DHT. async fn get_closest_peers_internal( &self, key: Multihash, + acquire_permit: bool, ) -> Result, GetClosestPeersError> { - let permit = self.shared.rate_limiter.acquire_kademlia_permit().await; + let permit = if acquire_permit { + Some(self.shared.rate_limiter.acquire_kademlia_permit().await) + } else { + None + }; + trace!(?key, "Starting 'GetClosestPeers' request."); let (result_sender, result_receiver) = mpsc::unbounded(); @@ -602,7 +608,7 @@ impl NodeRequestsBatchHandle { &mut self, key: Multihash, ) -> Result, GetClosestPeersError> { - self.node.get_closest_peers_internal(key).await + self.node.get_closest_peers_internal(key, false).await } /// Sends the generic request to the peer and awaits the result. pub async fn send_generic_request( diff --git a/crates/subspace-networking/src/node_runner.rs b/crates/subspace-networking/src/node_runner.rs index ef6e17683c..22bcdbbbe4 100644 --- a/crates/subspace-networking/src/node_runner.rs +++ b/crates/subspace-networking/src/node_runner.rs @@ -60,7 +60,7 @@ enum QueryResultSender { ClosestPeers { sender: mpsc::UnboundedSender, // Just holding onto permit while data structure is not dropped - _permit: RateLimiterPermit, + _permit: Option, }, Providers { sender: mpsc::UnboundedSender, diff --git a/crates/subspace-networking/src/shared.rs b/crates/subspace-networking/src/shared.rs index 8ab72c54f5..3121bb9a41 100644 --- a/crates/subspace-networking/src/shared.rs +++ b/crates/subspace-networking/src/shared.rs @@ -79,7 +79,7 @@ pub(crate) enum Command { GetClosestPeers { key: Multihash, result_sender: mpsc::UnboundedSender, - permit: RateLimiterPermit, + permit: Option, }, GenericRequest { peer_id: PeerId,