@@ -1381,6 +1381,10 @@ where
1381
1381
1382
1382
pending_offers_messages: Mutex<Vec<PendingOnionMessage<OffersMessage>>>,
1383
1383
1384
+ /// Tracks the channel_update message that were not broadcasted because
1385
+ /// we were not connected to any peers.
1386
+ pending_broadcast_messages: Mutex<Vec<MessageSendEvent>>,
1387
+
1384
1388
entropy_source: ES,
1385
1389
node_signer: NS,
1386
1390
signer_provider: SP,
@@ -2455,6 +2459,7 @@ where
2455
2459
funding_batch_states: Mutex::new(BTreeMap::new()),
2456
2460
2457
2461
pending_offers_messages: Mutex::new(Vec::new()),
2462
+ pending_broadcast_messages: Mutex::new(Vec::new()),
2458
2463
2459
2464
entropy_source,
2460
2465
node_signer,
@@ -2946,17 +2951,12 @@ where
2946
2951
}
2947
2952
};
2948
2953
if let Some(update) = update_opt {
2949
- // Try to send the `BroadcastChannelUpdate` to the peer we just force-closed on, but if
2950
- // not try to broadcast it via whatever peer we have.
2951
- let per_peer_state = self.per_peer_state.read().unwrap();
2952
- let a_peer_state_opt = per_peer_state.get(peer_node_id)
2953
- .ok_or(per_peer_state.values().next());
2954
- if let Ok(a_peer_state_mutex) = a_peer_state_opt {
2955
- let mut a_peer_state = a_peer_state_mutex.lock().unwrap();
2956
- a_peer_state.pending_msg_events.push(events::MessageSendEvent::BroadcastChannelUpdate {
2957
- msg: update
2958
- });
2959
- }
2954
+ // If we have some Channel Update to broadcast, we cache it and broadcast it later.
2955
+ let mut pending_broadcast_messages = self.pending_broadcast_messages.lock().unwrap();
2956
+ pending_broadcast_messages.push(events::MessageSendEvent::BroadcastChannelUpdate {
2957
+ msg: update
2958
+ });
2959
+ log_trace!(self.logger, "Caching the channel_updates of force-closed channel. We will them broadcast later.");
2960
2960
}
2961
2961
2962
2962
Ok(counterparty_node_id)
@@ -8203,6 +8203,8 @@ where
8203
8203
pending_events.append(&mut peer_state.pending_msg_events);
8204
8204
}
8205
8205
}
8206
+ let mut broadcast_msgs = self.pending_broadcast_messages.lock().unwrap();
8207
+ pending_events.append(&mut broadcast_msgs);
8206
8208
8207
8209
if !pending_events.is_empty() {
8208
8210
events.replace(pending_events);
@@ -11099,6 +11101,8 @@ where
11099
11101
11100
11102
pending_offers_messages: Mutex::new(Vec::new()),
11101
11103
11104
+ pending_broadcast_messages: Mutex::new(Vec::new()),
11105
+
11102
11106
entropy_source: args.entropy_source,
11103
11107
node_signer: args.node_signer,
11104
11108
signer_provider: args.signer_provider,
0 commit comments