@@ -930,10 +930,13 @@ impl<'a> HarnessNode<'a> {
930930 self . persister . mark_update_completed ( chan_id, monitor_id, data) ;
931931 }
932932
933- fn complete_all_monitor_updates ( & self , chan_id : & ChannelId ) {
934- for ( monitor_id, data) in self . persister . drain_pending_updates ( chan_id) {
933+ fn complete_all_monitor_updates ( & self , chan_id : & ChannelId ) -> bool {
934+ let completed_updates = self . persister . drain_pending_updates ( chan_id) ;
935+ let completed_any = !completed_updates. is_empty ( ) ;
936+ for ( monitor_id, data) in completed_updates {
935937 self . finish_monitor_update ( * chan_id, monitor_id, data) ;
936938 }
939+ completed_any
937940 }
938941
939942 fn complete_all_pending_monitor_updates ( & self ) {
@@ -966,9 +969,12 @@ impl<'a> HarnessNode<'a> {
966969 }
967970 }
968971
969- fn refresh_serialized_manager ( & mut self ) {
972+ fn refresh_serialized_manager ( & mut self ) -> bool {
970973 if self . node . get_and_clear_needs_persistence ( ) {
971974 self . serialized_manager = self . node . encode ( ) ;
975+ true
976+ } else {
977+ false
972978 }
973979 }
974980
@@ -1362,11 +1368,13 @@ impl PeerLink {
13621368 || ( self . node_a == node_b && self . node_b == node_a)
13631369 }
13641370
1365- fn complete_all_monitor_updates ( & self , nodes : & [ HarnessNode < ' _ > ; 3 ] ) {
1371+ fn complete_all_monitor_updates ( & self , nodes : & [ HarnessNode < ' _ > ; 3 ] ) -> bool {
1372+ let mut completed_updates = false ;
13661373 for id in & self . channel_ids {
1367- nodes[ self . node_a ] . complete_all_monitor_updates ( id) ;
1368- nodes[ self . node_b ] . complete_all_monitor_updates ( id) ;
1374+ completed_updates |= nodes[ self . node_a ] . complete_all_monitor_updates ( id) ;
1375+ completed_updates |= nodes[ self . node_b ] . complete_all_monitor_updates ( id) ;
13691376 }
1377+ completed_updates
13701378 }
13711379
13721380 fn complete_monitor_updates_for_node (
@@ -2143,7 +2151,6 @@ impl<'a, Out: Output + MaybeSend + MaybeSync> Harness<'a, Out> {
21432151 ChannelMonitorUpdateStatus :: Completed
21442152 } ,
21452153 ] ;
2146-
21472154 let wallet_a = TestWalletSource :: new ( SecretKey :: from_slice ( & [ 1 ; 32 ] ) . unwrap ( ) ) ;
21482155 let wallet_b = TestWalletSource :: new ( SecretKey :: from_slice ( & [ 2 ; 32 ] ) . unwrap ( ) ) ;
21492156 let wallet_c = TestWalletSource :: new ( SecretKey :: from_slice ( & [ 3 ; 32 ] ) . unwrap ( ) ) ;
@@ -2671,7 +2678,7 @@ impl<'a, Out: Output + MaybeSend + MaybeSync> Harness<'a, Out> {
26712678 // claim/fail handling per event batch.
26722679 let mut claim_set = new_hash_map ( ) ;
26732680 let mut events = nodes[ node_idx] . get_and_clear_pending_events ( ) ;
2674- let had_events = !events. is_empty ( ) ;
2681+ let mut had_events = !events. is_empty ( ) ;
26752682 for event in events. drain ( ..) {
26762683 match event {
26772684 events:: Event :: PaymentClaimable { payment_hash, .. } => {
@@ -2727,6 +2734,7 @@ impl<'a, Out: Output + MaybeSend + MaybeSync> Harness<'a, Out> {
27272734 }
27282735 while nodes[ node_idx] . needs_pending_htlc_processing ( ) {
27292736 nodes[ node_idx] . process_pending_htlc_forwards ( ) ;
2737+ had_events = true ;
27302738 }
27312739 had_events
27322740 }
@@ -2749,9 +2757,10 @@ impl<'a, Out: Output + MaybeSend + MaybeSync> Harness<'a, Out> {
27492757 "It may take may iterations to settle the state, but it should not take forever"
27502758 ) ;
27512759 }
2760+ let mut made_progress = self . refresh_serialized_managers ( ) ;
27522761 // Next, make sure no monitor completion callbacks are pending.
2753- self . ab_link . complete_all_monitor_updates ( & self . nodes ) ;
2754- self . bc_link . complete_all_monitor_updates ( & self . nodes ) ;
2762+ made_progress |= self . ab_link . complete_all_monitor_updates ( & self . nodes ) ;
2763+ made_progress |= self . bc_link . complete_all_monitor_updates ( & self . nodes ) ;
27552764 // Then, make sure any current forwards make their way to their destination.
27562765 if self . process_msg_events ( 0 , false , ProcessMessages :: AllMessages ) {
27572766 last_pass_no_updates = false ;
@@ -2778,6 +2787,10 @@ impl<'a, Out: Output + MaybeSend + MaybeSync> Harness<'a, Out> {
27782787 last_pass_no_updates = false ;
27792788 continue ;
27802789 }
2790+ if made_progress {
2791+ last_pass_no_updates = false ;
2792+ continue ;
2793+ }
27812794 if last_pass_no_updates {
27822795 // In some cases, we may generate a message to send in
27832796 // `process_msg_events`, but block sending until
@@ -2876,10 +2889,12 @@ impl<'a, Out: Output + MaybeSend + MaybeSync> Harness<'a, Out> {
28762889 self . nodes [ 2 ] . record_last_htlc_clear_fee ( ) ;
28772890 }
28782891
2879- fn refresh_serialized_managers ( & mut self ) {
2892+ fn refresh_serialized_managers ( & mut self ) -> bool {
2893+ let mut made_progress = false ;
28802894 for node in & mut self . nodes {
2881- node. refresh_serialized_manager ( ) ;
2895+ made_progress |= node. refresh_serialized_manager ( ) ;
28822896 }
2897+ made_progress
28832898 }
28842899}
28852900
0 commit comments