@@ -19,7 +19,6 @@ use crate::types::{
1919const PROCESS_EVENTS_INTERVAL : Duration = Duration :: from_millis ( 1000 ) ;
2020const PEER_MANAGER_PING_INTERVAL : Duration = Duration :: from_secs ( 15 ) ;
2121const CHANNEL_MANAGER_TICK_INTERVAL : Duration = Duration :: from_secs ( 60 ) ;
22- const CHANNEL_MANAGER_POLL_INTERVAL : Duration = Duration :: from_millis ( 1000 ) ;
2322const NETWORK_GRAPH_INITIAL_DELAY : Duration = Duration :: from_secs ( 60 ) ;
2423const NETWORK_GRAPH_PRUNE_INTERVAL : Duration = Duration :: from_secs ( 15 * 60 ) ;
2524const PROB_SCORER_PERSIST_INTERVAL : Duration = Duration :: from_secs ( 5 * 60 ) ;
@@ -46,7 +45,6 @@ impl LexeBackgroundProcessor {
4645 let mut process_timer = interval ( PROCESS_EVENTS_INTERVAL ) ;
4746 let mut pm_timer = interval ( PEER_MANAGER_PING_INTERVAL ) ;
4847 let mut cm_tick_timer = interval ( CHANNEL_MANAGER_TICK_INTERVAL ) ;
49- let mut cm_poll_timer = interval ( CHANNEL_MANAGER_POLL_INTERVAL ) ;
5048 let start = Instant :: now ( ) + NETWORK_GRAPH_INITIAL_DELAY ;
5149 let mut ng_timer = interval_at ( start, NETWORK_GRAPH_PRUNE_INTERVAL ) ;
5250 let mut ps_timer = interval ( PROB_SCORER_PERSIST_INTERVAL ) ;
@@ -72,25 +70,19 @@ impl LexeBackgroundProcessor {
7270 }
7371
7472 // --- Persistence branches --- //
75- _ = cm_poll_timer. tick( ) => {
76- trace!( "Polling channel manager for updates" ) ;
77- // TODO Use get_persistence_condvar_value instead
78- let timeout = Duration :: from_millis( 10 ) ;
79- let needs_persist = channel_manager
80- . await_persistable_update_timeout( timeout) ;
81- if needs_persist {
82- let persist_res = persister
83- . persist_manager( channel_manager. deref( ) )
84- . await ;
85- if let Err ( e) = persist_res {
86- // Failing to persist the channel manager won't
87- // lose funds so long as the chain monitors have
88- // been persisted correctly, but it's still
89- // serious - initiate a shutdown
90- error!( "Couldn't persist channel manager: {:#}" , e) ;
91- let _ = shutdown_tx. send( ( ) ) ;
92- break ;
93- }
73+ _ = channel_manager. get_persistable_update_future( ) => {
74+ debug!( "Persisting channel manager" ) ;
75+ let persist_res = persister
76+ . persist_manager( channel_manager. deref( ) )
77+ . await ;
78+ if let Err ( e) = persist_res {
79+ // Failing to persist the channel manager won't
80+ // lose funds so long as the chain monitors have
81+ // been persisted correctly, but it's still
82+ // serious - initiate a shutdown
83+ error!( "Couldn't persist channel manager: {:#}" , e) ;
84+ let _ = shutdown_tx. send( ( ) ) ;
85+ break ;
9486 }
9587 }
9688 _ = ng_timer. tick( ) => {
0 commit comments