@@ -2140,39 +2140,42 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2140
2140
///
2141
2141
/// Note that in some rare cases this may generate a `chain::Watch::update_channel` call.
2142
2142
pub fn timer_tick_occurred ( & self ) {
2143
- let should_persist = std :: cell :: RefCell :: new ( PersistenceGuardOption :: SkipPersist ) ;
2144
- let mut _persistence_guard = PersistenceNotifierGuard :: optionally_persist ( & self . total_consistency_lock , & self . persistence_notifier , || * should_persist . borrow ( ) ) ;
2145
- if self . process_background_events ( ) { * should_persist. borrow_mut ( ) = PersistenceGuardOption :: DoPersist ; }
2143
+ PersistenceNotifierGuard :: optionally_persist ( & self . total_consistency_lock , & self . persistence_notifier , || {
2144
+ let mut should_persist = PersistenceGuardOption :: SkipPersist ;
2145
+ if self . process_background_events ( ) { should_persist = PersistenceGuardOption :: DoPersist ; }
2146
2146
2147
- let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
2148
- let channel_state = & mut * channel_state_lock;
2149
- for ( _, chan) in channel_state. by_id . iter_mut ( ) {
2150
- match chan. get_update_status ( ) {
2151
- UpdateStatus :: Enabled if !chan. is_live ( ) => chan. set_update_status ( UpdateStatus :: DisabledStaged ) ,
2152
- UpdateStatus :: Disabled if chan. is_live ( ) => chan. set_update_status ( UpdateStatus :: EnabledStaged ) ,
2153
- UpdateStatus :: DisabledStaged if chan. is_live ( ) => chan. set_update_status ( UpdateStatus :: Enabled ) ,
2154
- UpdateStatus :: EnabledStaged if !chan. is_live ( ) => chan. set_update_status ( UpdateStatus :: Disabled ) ,
2155
- UpdateStatus :: DisabledStaged if !chan. is_live ( ) => {
2156
- if let Ok ( update) = self . get_channel_update ( & chan) {
2157
- channel_state. pending_msg_events . push ( events:: MessageSendEvent :: BroadcastChannelUpdate {
2158
- msg : update
2159
- } ) ;
2160
- }
2161
- * should_persist. borrow_mut ( ) = PersistenceGuardOption :: DoPersist ;
2162
- chan. set_update_status ( UpdateStatus :: Disabled ) ;
2163
- } ,
2164
- UpdateStatus :: EnabledStaged if chan. is_live ( ) => {
2165
- if let Ok ( update) = self . get_channel_update ( & chan) {
2166
- channel_state. pending_msg_events . push ( events:: MessageSendEvent :: BroadcastChannelUpdate {
2167
- msg : update
2168
- } ) ;
2169
- }
2170
- * should_persist. borrow_mut ( ) = PersistenceGuardOption :: DoPersist ;
2171
- chan. set_update_status ( UpdateStatus :: Enabled ) ;
2172
- } ,
2173
- _ => { } ,
2147
+ let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
2148
+ let channel_state = & mut * channel_state_lock;
2149
+ for ( _, chan) in channel_state. by_id . iter_mut ( ) {
2150
+ match chan. get_update_status ( ) {
2151
+ UpdateStatus :: Enabled if !chan. is_live ( ) => chan. set_update_status ( UpdateStatus :: DisabledStaged ) ,
2152
+ UpdateStatus :: Disabled if chan. is_live ( ) => chan. set_update_status ( UpdateStatus :: EnabledStaged ) ,
2153
+ UpdateStatus :: DisabledStaged if chan. is_live ( ) => chan. set_update_status ( UpdateStatus :: Enabled ) ,
2154
+ UpdateStatus :: EnabledStaged if !chan. is_live ( ) => chan. set_update_status ( UpdateStatus :: Disabled ) ,
2155
+ UpdateStatus :: DisabledStaged if !chan. is_live ( ) => {
2156
+ if let Ok ( update) = self . get_channel_update ( & chan) {
2157
+ channel_state. pending_msg_events . push ( events:: MessageSendEvent :: BroadcastChannelUpdate {
2158
+ msg : update
2159
+ } ) ;
2160
+ }
2161
+ should_persist = PersistenceGuardOption :: DoPersist ;
2162
+ chan. set_update_status ( UpdateStatus :: Disabled ) ;
2163
+ } ,
2164
+ UpdateStatus :: EnabledStaged if chan. is_live ( ) => {
2165
+ if let Ok ( update) = self . get_channel_update ( & chan) {
2166
+ channel_state. pending_msg_events . push ( events:: MessageSendEvent :: BroadcastChannelUpdate {
2167
+ msg : update
2168
+ } ) ;
2169
+ }
2170
+ should_persist = PersistenceGuardOption :: DoPersist ;
2171
+ chan. set_update_status ( UpdateStatus :: Enabled ) ;
2172
+ } ,
2173
+ _ => { } ,
2174
+ }
2174
2175
}
2175
- }
2176
+
2177
+ should_persist
2178
+ } ) ;
2176
2179
}
2177
2180
2178
2181
/// Indicates that the preimage for payment_hash is unknown or the received amount is incorrect
0 commit comments