diff --git a/src/service.rs b/src/service.rs index cb5c3af75..716a84354 100644 --- a/src/service.rs +++ b/src/service.rs @@ -638,7 +638,7 @@ impl Service { event = Service::bucket_maintenance_poll(&self.kbuckets) => { self.send_event(event); } - Some(event) = Service::bucket_maintenance_poll_topics(self.topics_kbuckets.iter_mut()) => { + Some(event) = Service::bucket_maintenance_poll_topics(KBuckets::Topic (self.topics_kbuckets.iter_mut())) => { self.send_event(event); } query_event = Service::query_event_poll(&mut self.queries) => { @@ -2308,34 +2308,13 @@ impl Service { /// A future that maintains the topic kbuckets and inserts nodes when required. This returns the /// `Discv5Event::NodeInsertedTopics` variants. - async fn bucket_maintenance_poll_topics( - kbuckets: KBuckets<'_, Box)> + '_>>, + async fn bucket_maintenance_poll_topics< + 'a, + T: Iterator)>, + >( + kbuckets: KBuckets<'a, T>, ) -> Option { - // Drain applied pending entries from the routing table. - let mut update_kbuckets_futures = Vec::new(); - for entry in kbuckets { - let (topic_hash, kbuckets) = match kbuckets { - KBuckets::Topic => (Some(entry.0), entry.1), - KBuckets::Local => (None, entry) - }; - update_kbuckets_futures.push(future::poll_fn(move |_cx| { - if let Some(entry) = (*topic_kbuckets).take_applied_pending() { - let event = Discv5Event::NodeInsertedTopic { - node_id: entry.inserted.into_preimage(), - replaced: entry.evicted.map(|n| n.key.into_preimage()), - topic_hash: *topic_hash, - }; - return Poll::Ready(event); - } - Poll::Pending - })); - } - if update_kbuckets_futures.is_empty() { - None - } else { - let (event, _, _) = select_all(update_kbuckets_futures).await; - Some(event) - } + None } /// A future the maintains active queries. This returns completed and timed out queries, as @@ -2397,8 +2376,9 @@ enum ConnectionStatus { } /// The separate layers of kbuckets that exist. -enum KBuckets<'a, T: Iterator)>> { +enum KBuckets<'a, T: Iterator)>> { /// One set of local kbuckets exist, this is the local routing table. - Local(Arc>>), + Local(&'a Arc>>), Topic(T), -} \ No newline at end of file +} +