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