@@ -3665,19 +3665,23 @@ macro_rules! handle_new_monitor_update {
3665
3665
$self: ident, $funding_txo: expr, $update: expr, $peer_state: expr, $logger: expr,
3666
3666
$chan_id: expr, $counterparty_node_id: expr, $in_flight_updates: ident, $update_idx: ident,
3667
3667
_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;
3671
3674
// During startup, we push monitor updates as background events through to here in
3672
3675
// order to replay updates that were in-flight when we shut down. Thus, we have to
3673
3676
// 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(|| {
3676
3679
$in_flight_updates.push($update);
3677
3680
$in_flight_updates.len() - 1
3678
3681
});
3679
3682
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]);
3681
3685
handle_new_monitor_update!($self, update_res, $logger, $chan_id, _internal, $completed)
3682
3686
} else {
3683
3687
// We blindly assume that the ChannelMonitorUpdate will be regenerated on startup if we
@@ -3700,62 +3704,101 @@ macro_rules! handle_new_monitor_update {
3700
3704
$self.pending_background_events.lock().unwrap().push(event);
3701
3705
false
3702
3706
}
3703
- } };
3707
+ }};
3704
3708
(
3705
3709
$self: ident, $funding_txo: expr, $update: expr, $peer_state: expr, $chan_context: expr,
3706
3710
REMAIN_LOCKED_UPDATE_ACTIONS_PROCESSED_LATER
3707
- ) => { {
3711
+ ) => {{
3708
3712
let logger = WithChannelContext::from(&$self.logger, &$chan_context, None);
3709
3713
let chan_id = $chan_context.channel_id();
3710
3714
let counterparty_node_id = $chan_context.get_counterparty_node_id();
3711
3715
let in_flight_updates;
3712
3716
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,
3715
3728
{
3716
3729
let _ = in_flight_updates.remove(idx);
3717
- })
3718
- } };
3730
+ }
3731
+ )
3732
+ }};
3719
3733
(
3720
3734
$self: ident, $funding_txo: expr, $update: expr, $peer_state_lock: expr, $peer_state: expr,
3721
3735
$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);
3724
3739
let in_flight_updates;
3725
3740
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,
3728
3752
{
3729
3753
let _ = in_flight_updates.remove(idx);
3730
3754
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());
3733
3759
3734
3760
mem::drop($peer_state_lock);
3735
3761
mem::drop($per_peer_state_lock);
3736
3762
3737
3763
$self.handle_monitor_update_completion_actions(update_actions);
3738
3764
}
3739
- })
3740
- } };
3765
+ }
3766
+ )
3767
+ }};
3741
3768
(
3742
3769
$self: ident, $funding_txo: expr, $update: expr, $peer_state_lock: expr, $peer_state: expr,
3743
3770
$per_peer_state_lock: expr, $chan: expr
3744
- ) => { {
3771
+ ) => {{
3745
3772
let logger = WithChannelContext::from(&$self.logger, &$chan.context, None);
3746
3773
let chan_id = $chan.context.channel_id();
3747
3774
let counterparty_node_id = $chan.context.get_counterparty_node_id();
3748
3775
let in_flight_updates;
3749
3776
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,
3752
3788
{
3753
3789
let _ = in_flight_updates.remove(idx);
3754
3790
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
+ );
3756
3798
}
3757
- })
3758
- } };
3799
+ }
3800
+ )
3801
+ }};
3759
3802
}
3760
3803
3761
3804
#[rustfmt::skip]
0 commit comments