@@ -3665,19 +3665,23 @@ macro_rules! handle_new_monitor_update {
36653665 $self: ident, $funding_txo: expr, $update: expr, $peer_state: expr, $logger: expr,
36663666 $chan_id: expr, $counterparty_node_id: expr, $in_flight_updates: ident, $update_idx: ident,
36673667 _internal_outer, $completed: expr
3668- ) => { {
3669- $in_flight_updates = &mut $peer_state.in_flight_monitor_updates.entry($chan_id)
3670- .or_insert_with(|| ($funding_txo, Vec::new())).1;
3668+ ) => {{
3669+ $in_flight_updates = &mut $peer_state
3670+ .in_flight_monitor_updates
3671+ .entry($chan_id)
3672+ .or_insert_with(|| ($funding_txo, Vec::new()))
3673+ .1;
36713674 // During startup, we push monitor updates as background events through to here in
36723675 // order to replay updates that were in-flight when we shut down. Thus, we have to
36733676 // filter for uniqueness here.
3674- $update_idx = $in_flight_updates.iter().position(|upd| upd == &$update)
3675- .unwrap_or_else(|| {
3677+ $update_idx =
3678+ $in_flight_updates.iter().position(|upd| upd == &$update) .unwrap_or_else(|| {
36763679 $in_flight_updates.push($update);
36773680 $in_flight_updates.len() - 1
36783681 });
36793682 if $self.background_events_processed_since_startup.load(Ordering::Acquire) {
3680- let update_res = $self.chain_monitor.update_channel($chan_id, &$in_flight_updates[$update_idx]);
3683+ let update_res =
3684+ $self.chain_monitor.update_channel($chan_id, &$in_flight_updates[$update_idx]);
36813685 handle_new_monitor_update!($self, update_res, $logger, $chan_id, _internal, $completed)
36823686 } else {
36833687 // We blindly assume that the ChannelMonitorUpdate will be regenerated on startup if we
@@ -3700,62 +3704,101 @@ macro_rules! handle_new_monitor_update {
37003704 $self.pending_background_events.lock().unwrap().push(event);
37013705 false
37023706 }
3703- } };
3707+ }};
37043708 (
37053709 $self: ident, $funding_txo: expr, $update: expr, $peer_state: expr, $chan_context: expr,
37063710 REMAIN_LOCKED_UPDATE_ACTIONS_PROCESSED_LATER
3707- ) => { {
3711+ ) => {{
37083712 let logger = WithChannelContext::from(&$self.logger, &$chan_context, None);
37093713 let chan_id = $chan_context.channel_id();
37103714 let counterparty_node_id = $chan_context.get_counterparty_node_id();
37113715 let in_flight_updates;
37123716 let idx;
3713- handle_new_monitor_update!($self, $funding_txo, $update, $peer_state, logger, chan_id,
3714- counterparty_node_id, in_flight_updates, idx, _internal_outer,
3717+ handle_new_monitor_update!(
3718+ $self,
3719+ $funding_txo,
3720+ $update,
3721+ $peer_state,
3722+ logger,
3723+ chan_id,
3724+ counterparty_node_id,
3725+ in_flight_updates,
3726+ idx,
3727+ _internal_outer,
37153728 {
37163729 let _ = in_flight_updates.remove(idx);
3717- })
3718- } };
3730+ }
3731+ )
3732+ }};
37193733 (
37203734 $self: ident, $funding_txo: expr, $update: expr, $peer_state_lock: expr, $peer_state: expr,
37213735 $per_peer_state_lock: expr, $counterparty_node_id: expr, $channel_id: expr, POST_CHANNEL_CLOSE
3722- ) => { {
3723- let logger = WithContext::from(&$self.logger, Some($counterparty_node_id), Some($channel_id), None);
3736+ ) => {{
3737+ let logger =
3738+ WithContext::from(&$self.logger, Some($counterparty_node_id), Some($channel_id), None);
37243739 let in_flight_updates;
37253740 let idx;
3726- handle_new_monitor_update!($self, $funding_txo, $update, $peer_state, logger,
3727- $channel_id, $counterparty_node_id, in_flight_updates, idx, _internal_outer,
3741+ handle_new_monitor_update!(
3742+ $self,
3743+ $funding_txo,
3744+ $update,
3745+ $peer_state,
3746+ logger,
3747+ $channel_id,
3748+ $counterparty_node_id,
3749+ in_flight_updates,
3750+ idx,
3751+ _internal_outer,
37283752 {
37293753 let _ = in_flight_updates.remove(idx);
37303754 if in_flight_updates.is_empty() {
3731- let update_actions = $peer_state.monitor_update_blocked_actions
3732- .remove(&$channel_id).unwrap_or(Vec::new());
3755+ let update_actions = $peer_state
3756+ .monitor_update_blocked_actions
3757+ .remove(&$channel_id)
3758+ .unwrap_or(Vec::new());
37333759
37343760 mem::drop($peer_state_lock);
37353761 mem::drop($per_peer_state_lock);
37363762
37373763 $self.handle_monitor_update_completion_actions(update_actions);
37383764 }
3739- })
3740- } };
3765+ }
3766+ )
3767+ }};
37413768 (
37423769 $self: ident, $funding_txo: expr, $update: expr, $peer_state_lock: expr, $peer_state: expr,
37433770 $per_peer_state_lock: expr, $chan: expr
3744- ) => { {
3771+ ) => {{
37453772 let logger = WithChannelContext::from(&$self.logger, &$chan.context, None);
37463773 let chan_id = $chan.context.channel_id();
37473774 let counterparty_node_id = $chan.context.get_counterparty_node_id();
37483775 let in_flight_updates;
37493776 let idx;
3750- handle_new_monitor_update!($self, $funding_txo, $update, $peer_state, logger, chan_id,
3751- counterparty_node_id, in_flight_updates, idx, _internal_outer,
3777+ handle_new_monitor_update!(
3778+ $self,
3779+ $funding_txo,
3780+ $update,
3781+ $peer_state,
3782+ logger,
3783+ chan_id,
3784+ counterparty_node_id,
3785+ in_flight_updates,
3786+ idx,
3787+ _internal_outer,
37523788 {
37533789 let _ = in_flight_updates.remove(idx);
37543790 if in_flight_updates.is_empty() && $chan.blocked_monitor_updates_pending() == 0 {
3755- handle_monitor_update_completion!($self, $peer_state_lock, $peer_state, $per_peer_state_lock, $chan);
3791+ handle_monitor_update_completion!(
3792+ $self,
3793+ $peer_state_lock,
3794+ $peer_state,
3795+ $per_peer_state_lock,
3796+ $chan
3797+ );
37563798 }
3757- })
3758- } };
3799+ }
3800+ )
3801+ }};
37593802}
37603803
37613804#[rustfmt::skip]
0 commit comments