X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-background-processor%2Fsrc%2Flib.rs;h=27cd0663e3291f27e385787d99769553c012de80;hb=e61f3a238a70cbac87209e223b7c396108a49b97;hp=938deee9bd7a0bc61f47387b18e77fa5a5b7c42b;hpb=a626828c96f307dd929c4734c6e6257d7a545e4f;p=rust-lightning diff --git a/lightning-background-processor/src/lib.rs b/lightning-background-processor/src/lib.rs index 938deee9..27cd0663 100644 --- a/lightning-background-processor/src/lib.rs +++ b/lightning-background-processor/src/lib.rs @@ -35,7 +35,7 @@ use std::time::{Duration, Instant}; use std::ops::Deref; #[cfg(feature = "futures")] -use futures::{select, future::FutureExt}; +use futures_util::{select_biased, future::FutureExt}; /// `BackgroundProcessor` takes care of tasks that (1) need to happen periodically to keep /// Rust-Lightning running properly, and (2) either can or should be run in the background. Its @@ -378,6 +378,7 @@ pub async fn process_events_async< Descriptor: 'static + SocketDescriptor + Send + Sync, CMH: 'static + Deref + Send + Sync, RMH: 'static + Deref + Send + Sync, + OMH: 'static + Deref + Send + Sync, EH: 'static + EventHandler + Send, PS: 'static + Deref + Send, M: 'static + Deref> + Send + Sync, @@ -385,7 +386,7 @@ pub async fn process_events_async< PGS: 'static + Deref> + Send + Sync, RGS: 'static + Deref> + Send, UMH: 'static + Deref + Send + Sync, - PM: 'static + Deref> + Send + Sync, + PM: 'static + Deref> + Send + Sync, S: 'static + Deref + Send + Sync, SC: WriteableScore<'a>, SleepFuture: core::future::Future, @@ -405,6 +406,7 @@ where L::Target: 'static + Logger, P::Target: 'static + Persist, CMH::Target: 'static + ChannelMessageHandler, + OMH::Target: 'static + OnionMessageHandler, RMH::Target: 'static + RoutingMessageHandler, UMH::Target: 'static + CustomMessageHandler, PS::Target: 'static + Persister<'a, Signer, CW, T, K, F, L, SC>, @@ -412,7 +414,7 @@ where let mut should_continue = true; define_run_body!(persister, event_handler, chain_monitor, channel_manager, gossip_sync, peer_manager, logger, scorer, should_continue, { - select! { + select_biased! { _ = channel_manager.get_persistable_update_future().fuse() => true, cont = sleeper(Duration::from_millis(100)).fuse() => { should_continue = cont; @@ -607,7 +609,7 @@ mod tests { const EVENT_DEADLINE: u64 = 5 * FRESHNESS_TIMER; - #[derive(Clone, Eq, Hash, PartialEq)] + #[derive(Clone, Hash, PartialEq, Eq)] struct TestDescriptor{} impl SocketDescriptor for TestDescriptor { fn send_data(&mut self, _data: &[u8], _resume_read: bool) -> usize {