@@ -722,6 +722,8 @@ impl_writeable_tlv_based_enum!(SentHTLCId,
722722type PerSourcePendingForward =
723723 (u64, Option<PublicKey>, OutPoint, ChannelId, u128, Vec<(PendingHTLCInfo, u64)>);
724724
725+ type FailedHTLCForward = (HTLCSource, PaymentHash, HTLCFailReason, HTLCHandlingFailureType);
726+
725727mod fuzzy_channelmanager {
726728 use super::*;
727729
@@ -6315,24 +6317,12 @@ where
63156317 }
63166318 }
63176319
6318- /// Processes HTLCs which are pending waiting on random forward delay.
6319- ///
6320- /// Should only really ever be called in response to a PendingHTLCsForwardable event.
6321- /// Will likely generate further events.
6322- pub fn process_pending_htlc_forwards(&self) {
6323- let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
6324-
6325- self.process_pending_update_add_htlcs();
6326-
6327- let mut new_events = VecDeque::new();
6328- let mut failed_forwards = Vec::new();
6329- let mut phantom_receives: Vec<PerSourcePendingForward> = Vec::new();
6330- {
6331- let mut forward_htlcs = new_hash_map();
6332- mem::swap(&mut forward_htlcs, &mut self.forward_htlcs.lock().unwrap());
6333-
6334- for (short_chan_id, mut pending_forwards) in forward_htlcs {
6335- if short_chan_id != 0 {
6320+ #[rustfmt::skip]
6321+ fn process_forward_htlcs(
6322+ &self, short_chan_id: u64, pending_forwards: &mut Vec<HTLCForwardInfo>,
6323+ failed_forwards: &mut Vec<FailedHTLCForward>,
6324+ phantom_receives: &mut Vec<PerSourcePendingForward>,
6325+ ) {
63366326 let mut forwarding_counterparty = None;
63376327 macro_rules! forwarding_channel_not_found {
63386328 ($forward_infos: expr) => {
@@ -6450,15 +6440,15 @@ where
64506440 Some((cp_id, chan_id)) => (cp_id, chan_id),
64516441 None => {
64526442 forwarding_channel_not_found!(pending_forwards.drain(..));
6453- continue ;
6443+ return ;
64546444 },
64556445 };
64566446 forwarding_counterparty = Some(counterparty_node_id);
64576447 let per_peer_state = self.per_peer_state.read().unwrap();
64586448 let peer_state_mutex_opt = per_peer_state.get(&counterparty_node_id);
64596449 if peer_state_mutex_opt.is_none() {
64606450 forwarding_channel_not_found!(pending_forwards.drain(..));
6461- continue ;
6451+ return ;
64626452 }
64636453 let mut peer_state_lock = peer_state_mutex_opt.unwrap().lock().unwrap();
64646454 let peer_state = &mut *peer_state_lock;
@@ -6689,6 +6679,33 @@ where
66896679 }
66906680 }
66916681 }
6682+ }
6683+
6684+
6685+ /// Processes HTLCs which are pending waiting on random forward delay.
6686+ ///
6687+ /// Should only really ever be called in response to a PendingHTLCsForwardable event.
6688+ /// Will likely generate further events.
6689+ pub fn process_pending_htlc_forwards(&self) {
6690+ let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
6691+
6692+ self.process_pending_update_add_htlcs();
6693+
6694+ let mut new_events = VecDeque::new();
6695+ let mut failed_forwards = Vec::new();
6696+ let mut phantom_receives: Vec<PerSourcePendingForward> = Vec::new();
6697+ {
6698+ let mut forward_htlcs = new_hash_map();
6699+ mem::swap(&mut forward_htlcs, &mut self.forward_htlcs.lock().unwrap());
6700+
6701+ for (short_chan_id, mut pending_forwards) in forward_htlcs {
6702+ if short_chan_id != 0 {
6703+ self.process_forward_htlcs(
6704+ short_chan_id,
6705+ &mut pending_forwards,
6706+ &mut failed_forwards,
6707+ &mut phantom_receives,
6708+ );
66926709 } else {
66936710 'next_forwardable_htlc: for forward_info in pending_forwards.drain(..) {
66946711 match forward_info {
0 commit comments