@@ -262,19 +262,18 @@ where C::Target: chain::Filter,
262
262
FN : Fn ( & ChannelMonitor < ChannelSigner > , & TransactionData ) -> Vec < TransactionOutputs >
263
263
{
264
264
let mut dependent_txdata = Vec :: new ( ) ;
265
- if let Some ( height) = best_height {
266
- // Sadly AtomicUsize::fetch_max wasn't stabilized until 1.45, so until then we have to
267
- // manually CAS.
268
- let mut old_height = self . highest_chain_height . load ( Ordering :: Relaxed ) ;
269
- let new_height = height as usize ;
270
- while new_height > old_height && self . highest_chain_height
271
- . compare_exchange ( old_height, new_height, Ordering :: AcqRel , Ordering :: Relaxed ) . is_err ( )
272
- {
273
- old_height = self . highest_chain_height . load ( Ordering :: Acquire ) ;
274
- }
275
- }
276
265
{
277
266
let monitor_states = self . monitors . write ( ) . unwrap ( ) ;
267
+ if let Some ( height) = best_height {
268
+ // If the best block height is being updated, update highest_chain_height under the
269
+ // monitors write lock.
270
+ let old_height = self . highest_chain_height . load ( Ordering :: Acquire ) ;
271
+ let new_height = height as usize ;
272
+ if new_height > old_height {
273
+ self . highest_chain_height . store ( new_height, Ordering :: Release ) ;
274
+ }
275
+ }
276
+
278
277
for ( funding_outpoint, monitor_state) in monitor_states. iter ( ) {
279
278
let monitor = & monitor_state. monitor ;
280
279
let mut txn_outputs;
0 commit comments