Skip to content

Commit

Permalink
f improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Apr 5, 2023
1 parent 7a91ea9 commit e34dab6
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3644,6 +3644,10 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
if release_monitor { self.pending_monitor_updates.last().map(|upd| &upd.update) } else { None }));
}

let release_monitor = self.pending_monitor_updates.iter().all(|upd| !upd.blocked) && !hold_mon_update;
let release_state_str =
if hold_mon_update { "Holding" } else if release_monitor { "Releasing" } else { "Blocked" };

match self.free_holding_cell_htlcs(logger) {
(Some(_), htlcs_to_fail) => {
let mut additional_update = self.pending_monitor_updates.pop().unwrap().update;
Expand All @@ -3652,8 +3656,10 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
self.latest_monitor_update_id = monitor_update.update_id;
monitor_update.updates.append(&mut additional_update.updates);

log_debug!(logger, "Received a valid revoke_and_ack for channel {} with holding cell HTLCs freed. {} monitor update.",
log_bytes!(self.channel_id()), release_state_str);

self.monitor_updating_paused(false, true, false, to_forward_infos, revoked_htlcs, finalized_claimed_htlcs);
let release_monitor = self.pending_monitor_updates.iter().all(|upd| !upd.blocked) && !hold_mon_update;
self.pending_monitor_updates.push(PendingChannelMonitorUpdate {
update: monitor_update, blocked: !release_monitor,
});
Expand All @@ -3669,19 +3675,22 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
self.latest_monitor_update_id = monitor_update.update_id;
monitor_update.updates.append(&mut additional_update.updates);

log_debug!(logger, "Received a valid revoke_and_ack for channel {}. Responding with a commitment update with {} HTLCs failed.",
log_bytes!(self.channel_id()), update_fail_htlcs.len() + update_fail_malformed_htlcs.len());
log_debug!(logger, "Received a valid revoke_and_ack for channel {}. Responding with a commitment update with {} HTLCs failed. {} monitor update.",
log_bytes!(self.channel_id()),
update_fail_htlcs.len() + update_fail_malformed_htlcs.len(),
release_state_str);

self.monitor_updating_paused(false, true, false, to_forward_infos, revoked_htlcs, finalized_claimed_htlcs);
let release_monitor = self.pending_monitor_updates.iter().all(|upd| !upd.blocked) && !hold_mon_update;
self.pending_monitor_updates.push(PendingChannelMonitorUpdate {
update: monitor_update, blocked: !release_monitor,
});
Ok((htlcs_to_fail,
if release_monitor { self.pending_monitor_updates.last().map(|upd| &upd.update) } else { None }))
} else {
log_debug!(logger, "Received a valid revoke_and_ack for channel {} with no reply necessary.", log_bytes!(self.channel_id()));
log_debug!(logger, "Received a valid revoke_and_ack for channel {} with no reply necessary. {} monitor update.",
log_bytes!(self.channel_id()), release_state_str);

self.monitor_updating_paused(false, false, false, to_forward_infos, revoked_htlcs, finalized_claimed_htlcs);
let release_monitor = self.pending_monitor_updates.iter().all(|upd| !upd.blocked) && !hold_mon_update;
self.pending_monitor_updates.push(PendingChannelMonitorUpdate {
update: monitor_update, blocked: !release_monitor,
});
Expand Down

0 comments on commit e34dab6

Please sign in to comment.