@@ -2844,33 +2844,40 @@ where
2844
2844
}
2845
2845
};
2846
2846
if let Some(update) = update_opt {
2847
- // Try to send the `BroadcastChannelUpdate` to the peer we just force-closed on, but if
2848
- // not try to broadcast it via whatever peer we have.
2849
- let brodcast_message_evt = events::MessageSendEvent::BroadcastChannelUpdate {
2850
- msg: update
2851
- };
2847
+ PersistenceNotifierGuard::optionally_notify(self, || {
2848
+ let mut should_persist = NotifyOption::SkipPersistNoEvents;
2852
2849
2853
- let per_peer_state = self.per_peer_state.read().unwrap();
2850
+ // Try to send the `BroadcastChannelUpdate` to the peer we just force-closed on, but if
2851
+ // not try to broadcast it via whatever peer we have.
2852
+ let brodcast_message_evt = events::MessageSendEvent::BroadcastChannelUpdate {
2853
+ msg: update.clone()
2854
+ };
2854
2855
2855
- // Attempt to get the a_peer_state_mutex for the peer we disconnected on.
2856
- let a_peer_state_mutex_opt = per_peer_state.get(peer_node_id).map(|v| v);
2856
+ let per_peer_state = self.per_peer_state.read().unwrap();
2857
2857
2858
- // If the particular peer is not present. Select any random peer from the ones we are connected on.
2859
- let a_peer_state_mutex_opt = a_peer_state_mutex_opt.or_else(|| per_peer_state.iter().next(). map(|(_, v) | v) );
2858
+ // Attempt to get the a_peer_state_mutex for the peer we disconnected on.
2859
+ let a_peer_state_mutex_opt = per_peer_state.get(peer_node_id). map(|v | v);
2860
2860
2861
- match a_peer_state_mutex_opt {
2862
- Some(a_peer_state_mutex) => {
2863
- let mut a_peer_state = a_peer_state_mutex.lock().unwrap();
2864
- a_peer_state.pending_msg_events.push(brodcast_message_evt);
2865
- }
2866
- // If we are connected to no peer.
2867
- None => {
2868
- let mut pending_broadcast_messages = self.pending_broadcast_messages.lock().unwrap();
2869
- pending_broadcast_messages.push(brodcast_message_evt);
2870
- log_info!(self.logger, "Not able to broadcast channel_update of force-closed channel right now.
2871
- Will try rebroadcasting later.");
2861
+ // If the particular peer is not present. Select any random peer from the ones we are connected on.
2862
+ let a_peer_state_mutex_opt = a_peer_state_mutex_opt.or_else(|| per_peer_state.iter().next().map(|(_, v)| v));
2863
+
2864
+ match a_peer_state_mutex_opt {
2865
+ Some(a_peer_state_mutex) => {
2866
+ let mut a_peer_state = a_peer_state_mutex.lock().unwrap();
2867
+ a_peer_state.pending_msg_events.push(brodcast_message_evt);
2868
+ }
2869
+ // If we are connected to no peer.
2870
+ None => {
2871
+ let mut pending_broadcast_messages = self.pending_broadcast_messages.lock().unwrap();
2872
+ pending_broadcast_messages.push(brodcast_message_evt);
2873
+ log_info!(self.logger, "Not able to broadcast channel_update of force-closed channel right now.
2874
+ Will try rebroadcasting later.");
2875
+ should_persist = NotifyOption::DoPersist;
2876
+ }
2872
2877
}
2873
- }
2878
+ should_persist
2879
+ });
2880
+
2874
2881
}
2875
2882
2876
2883
Ok(counterparty_node_id)
@@ -4949,6 +4956,8 @@ where
4949
4956
a_peer_state.pending_msg_events.extend(broadcast_evts.iter().cloned());
4950
4957
4951
4958
self.pending_broadcast_messages.lock().unwrap().clear();
4959
+
4960
+ should_persist = NotifyOption::DoPersist;
4952
4961
}
4953
4962
}
4954
4963
0 commit comments