-#[cfg(feature = "futures")]
-async fn process_onion_message_handler_events_async<
- EventHandlerFuture: core::future::Future<Output = ()>,
- EventHandler: Fn(Event) -> EventHandlerFuture,
- PM: 'static + Deref + Send + Sync,
->(
- peer_manager: &PM, handler: EventHandler
-)
-where
- PM::Target: APeerManager + Send + Sync,
-{
- let events = core::cell::RefCell::new(Vec::new());
- peer_manager.onion_message_handler().process_pending_events(&|e| events.borrow_mut().push(e));
-
- for event in events.into_inner() {
- handler(event).await
- }
+fn onion_message_handler_events<PM: 'static + Deref + Send + Sync>(
+ peer_manager: &PM
+) -> impl Iterator<Item=Event> where PM::Target: APeerManager + Send + Sync {
+ peer_manager.onion_message_handler().get_and_clear_connections_needed()
+ .into_iter().map(|(node_id, addresses)| Event::ConnectionNeeded { node_id, addresses })