@@ -12,6 +12,8 @@ use crate::lsps0::msgs::{LSPSMessage, RawLSPSMessage, LSPS_MESSAGE_TYPE_ID};
1212use crate :: lsps0:: protocol:: LSPS0MessageHandler ;
1313use crate :: lsps2:: channel_manager:: JITChannelManager ;
1414use crate :: lsps2:: msgs:: { OpeningFeeParams , RawOpeningFeeParams } ;
15+ use crate :: prelude:: { HashMap , String , ToString , Vec } ;
16+ use crate :: sync:: { Arc , Mutex , RwLock } ;
1517
1618use lightning:: chain:: { self , BestBlock , Confirm , Filter , Listen } ;
1719use lightning:: ln:: channelmanager:: { AChannelManager , ChainParameters , InterceptId } ;
@@ -32,10 +34,8 @@ use bitcoin::BlockHash;
3234#[ cfg( lsps1) ]
3335use chrono:: Utc ;
3436
35- use std:: collections:: HashMap ;
36- use std:: convert:: TryFrom ;
37- use std:: ops:: Deref ;
38- use std:: sync:: { Arc , Mutex , RwLock } ;
37+ use core:: convert:: TryFrom ;
38+ use core:: ops:: Deref ;
3939
4040const LSPS_FEATURE_BIT : usize = 729 ;
4141
@@ -146,7 +146,7 @@ where
146146 ) -> Self
147147where {
148148 let pending_messages = Arc :: new ( Mutex :: new ( vec ! [ ] ) ) ;
149- let pending_events = Arc :: new ( EventQueue :: default ( ) ) ;
149+ let pending_events = Arc :: new ( EventQueue :: new ( ) ) ;
150150
151151 let lsps0_message_handler = LSPS0MessageHandler :: new (
152152 entropy_source. clone ( ) . clone ( ) ,
@@ -197,13 +197,21 @@ where {
197197 }
198198 }
199199
200- /// Blocks until next event is ready and returns it.
200+ /// Blocks the current thread until next event is ready and returns it.
201201 ///
202202 /// Typically you would spawn a thread or task that calls this in a loop.
203+ #[ cfg( feature = "std" ) ]
203204 pub fn wait_next_event ( & self ) -> Event {
204205 self . pending_events . wait_next_event ( )
205206 }
206207
208+ /// Returns `Some` if an event is ready.
209+ ///
210+ /// Typically you would spawn a thread or task that calls this in a loop.
211+ pub fn next_event ( & self ) -> Option < Event > {
212+ self . pending_events . next_event ( )
213+ }
214+
207215 /// Returns and clears all events without blocking.
208216 ///
209217 /// Typically you would spawn a thread or task that calls this in a loop.
0 commit comments