Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit ab09d44

Browse files
Remove multiple DHTs support from Discovery (#12524)
1 parent 967080b commit ab09d44

4 files changed

Lines changed: 297 additions & 473 deletions

File tree

client/network/src/behaviour.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use libp2p::{
3434

3535
use sc_consensus::import_queue::{IncomingBlock, RuntimeOrigin};
3636
use sc_network_common::{
37-
config::ProtocolId,
3837
protocol::{
3938
event::DhtEvent,
4039
role::{ObservedRole, Roles},
@@ -79,7 +78,7 @@ pub enum BehaviourOut<B: BlockT> {
7978
JustificationImport(RuntimeOrigin, B::Hash, NumberFor<B>, Justifications),
8079

8180
/// Started a random iterative Kademlia discovery query.
82-
RandomKademliaStarted(Vec<ProtocolId>),
81+
RandomKademliaStarted,
8382

8483
/// We have received a request from a peer and answered it.
8584
///
@@ -267,25 +266,20 @@ where
267266
self.discovery.add_known_address(peer_id, addr)
268267
}
269268

270-
/// Returns the number of nodes in each Kademlia kbucket for each Kademlia instance.
269+
/// Returns the number of nodes in each Kademlia kbucket.
271270
///
272-
/// Identifies Kademlia instances by their [`ProtocolId`] and kbuckets by the base 2 logarithm
273-
/// of their lower bound.
274-
pub fn num_entries_per_kbucket(
275-
&mut self,
276-
) -> impl ExactSizeIterator<Item = (&ProtocolId, Vec<(u32, usize)>)> {
271+
/// Identifies kbuckets by the base 2 logarithm of their lower bound.
272+
pub fn num_entries_per_kbucket(&mut self) -> Option<Vec<(u32, usize)>> {
277273
self.discovery.num_entries_per_kbucket()
278274
}
279275

280276
/// Returns the number of records in the Kademlia record stores.
281-
pub fn num_kademlia_records(&mut self) -> impl ExactSizeIterator<Item = (&ProtocolId, usize)> {
277+
pub fn num_kademlia_records(&mut self) -> Option<usize> {
282278
self.discovery.num_kademlia_records()
283279
}
284280

285281
/// Returns the total size in bytes of all the records in the Kademlia record stores.
286-
pub fn kademlia_records_total_size(
287-
&mut self,
288-
) -> impl ExactSizeIterator<Item = (&ProtocolId, usize)> {
282+
pub fn kademlia_records_total_size(&mut self) -> Option<usize> {
289283
self.discovery.kademlia_records_total_size()
290284
}
291285

@@ -438,8 +432,7 @@ impl<B: BlockT> From<DiscoveryOut> for BehaviourOut<B> {
438432
BehaviourOut::Dht(DhtEvent::ValuePut(key), duration),
439433
DiscoveryOut::ValuePutFailed(key, duration) =>
440434
BehaviourOut::Dht(DhtEvent::ValuePutFailed(key), duration),
441-
DiscoveryOut::RandomKademliaStarted(protocols) =>
442-
BehaviourOut::RandomKademliaStarted(protocols),
435+
DiscoveryOut::RandomKademliaStarted => BehaviourOut::RandomKademliaStarted,
443436
}
444437
}
445438
}

0 commit comments

Comments
 (0)