@@ -3245,18 +3245,17 @@ macro_rules! handle_monitor_update_completion {
3245
3245
}
3246
3246
3247
3247
macro_rules! handle_new_monitor_update {
3248
- ($self: ident, $update_res: expr, $chan : expr, _internal, $completed: expr) => { {
3248
+ ($self: ident, $update_res: expr, $logger: expr, $channel_id : expr, _internal, $completed: expr) => { {
3249
3249
debug_assert!($self.background_events_processed_since_startup.load(Ordering::Acquire));
3250
- let logger = WithChannelContext::from(&$self.logger, &$chan.context, None);
3251
3250
match $update_res {
3252
3251
ChannelMonitorUpdateStatus::UnrecoverableError => {
3253
3252
let err_str = "ChannelMonitor[Update] persistence failed unrecoverably. This indicates we cannot continue normal operation and must shut down.";
3254
- log_error!(logger, "{}", err_str);
3253
+ log_error!($ logger, "{}", err_str);
3255
3254
panic!("{}", err_str);
3256
3255
},
3257
3256
ChannelMonitorUpdateStatus::InProgress => {
3258
- log_debug!(logger, "ChannelMonitor update for {} in flight, holding messages until the update completes.",
3259
- &$chan.context. channel_id() );
3257
+ log_debug!($ logger, "ChannelMonitor update for {} in flight, holding messages until the update completes.",
3258
+ $ channel_id);
3260
3259
false
3261
3260
},
3262
3261
ChannelMonitorUpdateStatus::Completed => {
@@ -3266,22 +3265,52 @@ macro_rules! handle_new_monitor_update {
3266
3265
}
3267
3266
} };
3268
3267
($self: ident, $update_res: expr, $peer_state_lock: expr, $peer_state: expr, $per_peer_state_lock: expr, $chan: expr, INITIAL_MONITOR) => {
3269
- handle_new_monitor_update!($self, $update_res, $chan, _internal,
3268
+ let logger = WithChannelContext::from(&$self.logger, &$chan.context, None);
3269
+ handle_new_monitor_update!($self, $update_res, logger, $chan.context.channel_id(), _internal,
3270
3270
handle_monitor_update_completion!($self, $peer_state_lock, $peer_state, $per_peer_state_lock, $chan))
3271
3271
};
3272
- ($self: ident, $funding_txo: expr, $update: expr, $peer_state_lock: expr, $peer_state: expr, $per_peer_state_lock: expr, $chan: expr) => { {
3273
- let in_flight_updates = $peer_state.in_flight_monitor_updates.entry($funding_txo)
3272
+ (
3273
+ $self: ident, $funding_txo: expr, $update: expr, $peer_state: expr, $logger: expr,
3274
+ $chan_id: expr, $in_flight_updates: ident, $update_idx: ident, _internal_outer,
3275
+ $completed: expr
3276
+ ) => { {
3277
+ $in_flight_updates = $peer_state.in_flight_monitor_updates.entry($funding_txo)
3274
3278
.or_insert_with(Vec::new);
3275
3279
// During startup, we push monitor updates as background events through to here in
3276
3280
// order to replay updates that were in-flight when we shut down. Thus, we have to
3277
3281
// filter for uniqueness here.
3278
- let idx = in_flight_updates.iter().position(|upd| upd == &$update)
3282
+ $update_idx = $ in_flight_updates.iter().position(|upd| upd == &$update)
3279
3283
.unwrap_or_else(|| {
3280
- in_flight_updates.push($update);
3281
- in_flight_updates.len() - 1
3284
+ $ in_flight_updates.push($update);
3285
+ $ in_flight_updates.len() - 1
3282
3286
});
3283
- let update_res = $self.chain_monitor.update_channel($funding_txo, &in_flight_updates[idx]);
3284
- handle_new_monitor_update!($self, update_res, $chan, _internal,
3287
+ let update_res = $self.chain_monitor.update_channel($funding_txo, &$in_flight_updates[$update_idx]);
3288
+ handle_new_monitor_update!($self, update_res, $logger, $chan_id, _internal, $completed)
3289
+ } };
3290
+ (
3291
+ $self: ident, $funding_txo: expr, $update: expr, $peer_state: expr, $chan_context: expr,
3292
+ REMAIN_LOCKED_UPDATE_ACTIONS_PROCESSED_LATER
3293
+ ) => { {
3294
+ let logger = WithChannelContext::from(&$self.logger, &$chan_context, None);
3295
+ let chan_id = $chan_context.channel_id();
3296
+ let in_flight_updates;
3297
+ let idx;
3298
+ handle_new_monitor_update!($self, $funding_txo, $update, $peer_state, logger, chan_id,
3299
+ in_flight_updates, idx, _internal_outer,
3300
+ {
3301
+ let _ = in_flight_updates.remove(idx);
3302
+ })
3303
+ } };
3304
+ (
3305
+ $self: ident, $funding_txo: expr, $update: expr, $peer_state_lock: expr, $peer_state: expr,
3306
+ $per_peer_state_lock: expr, $chan: expr
3307
+ ) => { {
3308
+ let logger = WithChannelContext::from(&$self.logger, &$chan.context, None);
3309
+ let chan_id = $chan.context.channel_id();
3310
+ let in_flight_updates;
3311
+ let idx;
3312
+ handle_new_monitor_update!($self, $funding_txo, $update, $peer_state, logger, chan_id,
3313
+ in_flight_updates, idx, _internal_outer,
3285
3314
{
3286
3315
let _ = in_flight_updates.remove(idx);
3287
3316
if in_flight_updates.is_empty() && $chan.blocked_monitor_updates_pending() == 0 {
0 commit comments