Skip to content

Commit cafbd56

Browse files
committed
Add logger to monitor_updating_paused
1 parent 62c5849 commit cafbd56

2 files changed

Lines changed: 91 additions & 17 deletions

File tree

lightning/src/ln/channel.rs

Lines changed: 84 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7503,6 +7503,7 @@ where
75037503
Vec::new(),
75047504
Vec::new(),
75057505
Vec::new(),
7506+
logger,
75067507
);
75077508
UpdateFulfillCommitFetch::NewClaim { monitor_update, htlc_value_msat }
75087509
},
@@ -7912,7 +7913,7 @@ where
79127913

79137914
log_info!(logger, "Received initial commitment_signed from peer for channel {}", &self.context.channel_id());
79147915

7915-
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
7916+
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new(), logger);
79167917
self.context.interactive_tx_signing_session.as_mut().expect("signing session should be present").received_commitment_signed();
79177918
Ok(channel_monitor)
79187919
}
@@ -8016,7 +8017,15 @@ where
80168017
.as_mut()
80178018
.expect("Signing session must exist for negotiated pending splice")
80188019
.received_commitment_signed();
8019-
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
8020+
self.monitor_updating_paused(
8021+
false,
8022+
false,
8023+
false,
8024+
Vec::new(),
8025+
Vec::new(),
8026+
Vec::new(),
8027+
logger,
8028+
);
80208029

80218030
Ok(self.push_ret_blockable_mon_update(monitor_update))
80228031
}
@@ -8328,6 +8337,7 @@ where
83288337
Vec::new(),
83298338
Vec::new(),
83308339
Vec::new(),
8340+
logger,
83318341
);
83328342
return Ok(self.push_ret_blockable_mon_update(monitor_update));
83338343
}
@@ -8533,7 +8543,15 @@ where
85338543
if update_fee.is_some() { "a fee update, " } else { "" },
85348544
update_add_count, update_fulfill_count, update_fail_count);
85358545

8536-
self.monitor_updating_paused(false, true, false, Vec::new(), Vec::new(), Vec::new());
8546+
self.monitor_updating_paused(
8547+
false,
8548+
true,
8549+
false,
8550+
Vec::new(),
8551+
Vec::new(),
8552+
Vec::new(),
8553+
logger,
8554+
);
85378555
(self.push_ret_blockable_mon_update(monitor_update), htlcs_to_fail)
85388556
} else {
85398557
(None, Vec::new())
@@ -8911,6 +8929,7 @@ where
89118929
to_forward_infos,
89128930
revoked_htlcs,
89138931
finalized_claimed_htlcs,
8932+
logger,
89148933
);
89158934
return_with_htlcs_to_fail!(htlcs_to_fail);
89168935
},
@@ -8956,6 +8975,7 @@ where
89568975
to_forward_infos,
89578976
revoked_htlcs,
89588977
finalized_claimed_htlcs,
8978+
logger,
89598979
);
89608980
return_with_htlcs_to_fail!(htlcs_to_fail);
89618981
} else {
@@ -8969,6 +8989,7 @@ where
89698989
to_forward_infos,
89708990
revoked_htlcs,
89718991
finalized_claimed_htlcs,
8992+
logger,
89728993
);
89738994
return_with_htlcs_to_fail!(htlcs_to_fail);
89748995
}
@@ -9369,12 +9390,17 @@ where
93699390
/// [`ChannelManager`]: super::channelmanager::ChannelManager
93709391
/// [`chain::Watch`]: crate::chain::Watch
93719392
/// [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress
9372-
fn monitor_updating_paused(
9393+
fn monitor_updating_paused<L: Deref>(
93739394
&mut self, resend_raa: bool, resend_commitment: bool, resend_channel_ready: bool,
93749395
mut pending_forwards: Vec<(PendingHTLCInfo, u64)>,
93759396
mut pending_fails: Vec<(HTLCSource, PaymentHash, HTLCFailReason)>,
93769397
mut pending_finalized_claimed_htlcs: Vec<(HTLCSource, Option<AttributionData>)>,
9377-
) {
9398+
logger: &L,
9399+
) where
9400+
L::Target: Logger,
9401+
{
9402+
log_trace!(logger, "Pausing channel monitor updates");
9403+
93789404
self.context.monitor_pending_revoke_and_ack |= resend_raa;
93799405
self.context.monitor_pending_commitment_signed |= resend_commitment;
93809406
self.context.monitor_pending_channel_ready |= resend_channel_ready;
@@ -10425,12 +10451,16 @@ where
1042510451
}
1042610452
}
1042710453

10428-
pub fn shutdown(
10429-
&mut self, signer_provider: &SP, their_features: &InitFeatures, msg: &msgs::Shutdown,
10454+
pub fn shutdown<L: Deref>(
10455+
&mut self, logger: &L, signer_provider: &SP, their_features: &InitFeatures,
10456+
msg: &msgs::Shutdown,
1043010457
) -> Result<
1043110458
(Option<msgs::Shutdown>, Option<ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>),
1043210459
ChannelError,
10433-
> {
10460+
>
10461+
where
10462+
L::Target: Logger,
10463+
{
1043410464
if self.context.channel_state.is_peer_disconnected() {
1043510465
return Err(ChannelError::close(
1043610466
"Peer sent shutdown when we needed a channel_reestablish".to_owned(),
@@ -10535,7 +10565,15 @@ where
1053510565
}],
1053610566
channel_id: Some(self.context.channel_id()),
1053710567
};
10538-
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
10568+
self.monitor_updating_paused(
10569+
false,
10570+
false,
10571+
false,
10572+
Vec::new(),
10573+
Vec::new(),
10574+
Vec::new(),
10575+
logger,
10576+
);
1053910577
self.push_ret_blockable_mon_update(monitor_update)
1054010578
} else {
1054110579
None
@@ -11292,7 +11330,15 @@ where
1129211330
}],
1129311331
channel_id: Some(self.context.channel_id()),
1129411332
};
11295-
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
11333+
self.monitor_updating_paused(
11334+
false,
11335+
false,
11336+
false,
11337+
Vec::new(),
11338+
Vec::new(),
11339+
Vec::new(),
11340+
logger,
11341+
);
1129611342
let monitor_update = self.push_ret_blockable_mon_update(monitor_update);
1129711343

1129811344
let announcement_sigs =
@@ -13016,7 +13062,15 @@ where
1301613062
let can_add_htlc = send_res.map_err(|(_, msg)| ChannelError::Ignore(msg))?;
1301713063
if can_add_htlc {
1301813064
let monitor_update = self.build_commitment_no_status_check(logger);
13019-
self.monitor_updating_paused(false, true, false, Vec::new(), Vec::new(), Vec::new());
13065+
self.monitor_updating_paused(
13066+
false,
13067+
true,
13068+
false,
13069+
Vec::new(),
13070+
Vec::new(),
13071+
Vec::new(),
13072+
logger,
13073+
);
1302013074
Ok(self.push_ret_blockable_mon_update(monitor_update))
1302113075
} else {
1302213076
Ok(None)
@@ -13042,13 +13096,19 @@ where
1304213096

1304313097
/// Begins the shutdown process, getting a message for the remote peer and returning all
1304413098
/// holding cell HTLCs for payment failure.
13045-
pub fn get_shutdown(
13099+
pub fn get_shutdown<L: Deref>(
1304613100
&mut self, signer_provider: &SP, their_features: &InitFeatures,
1304713101
target_feerate_sats_per_kw: Option<u32>, override_shutdown_script: Option<ShutdownScript>,
13102+
logger: &L,
1304813103
) -> Result<
1304913104
(msgs::Shutdown, Option<ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>),
1305013105
APIError,
13051-
> {
13106+
>
13107+
where
13108+
L::Target: Logger,
13109+
{
13110+
let logger = WithChannelContext::from(logger, &self.context, None);
13111+
1305213112
if self.context.channel_state.is_local_stfu_sent()
1305313113
|| self.context.channel_state.is_remote_stfu_sent()
1305413114
|| self.context.channel_state.is_quiescent()
@@ -13133,7 +13193,15 @@ where
1313313193
}],
1313413194
channel_id: Some(self.context.channel_id()),
1313513195
};
13136-
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
13196+
self.monitor_updating_paused(
13197+
false,
13198+
false,
13199+
false,
13200+
Vec::new(),
13201+
Vec::new(),
13202+
Vec::new(),
13203+
&&logger,
13204+
);
1313713205
self.push_ret_blockable_mon_update(monitor_update)
1313813206
} else {
1313913207
None
@@ -13743,7 +13811,7 @@ where
1374313811

1374413812
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some()
1374513813
|| channel.context.signer_pending_channel_ready;
13746-
channel.monitor_updating_paused(false, false, need_channel_ready, Vec::new(), Vec::new(), Vec::new());
13814+
channel.monitor_updating_paused(false, false, need_channel_ready, Vec::new(), Vec::new(), Vec::new(), logger);
1374713815
Ok((channel, channel_monitor))
1374813816
}
1374913817

@@ -14030,7 +14098,7 @@ where
1403014098
};
1403114099
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some()
1403214100
|| channel.context.signer_pending_channel_ready;
14033-
channel.monitor_updating_paused(false, false, need_channel_ready, Vec::new(), Vec::new(), Vec::new());
14101+
channel.monitor_updating_paused(false, false, need_channel_ready, Vec::new(), Vec::new(), Vec::new(), logger);
1403414102

1403514103
Ok((channel, funding_signed, channel_monitor))
1403614104
}

lightning/src/ln/channelmanager.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4193,6 +4193,7 @@ where
41934193
their_features,
41944194
target_feerate_sats_per_1000_weight,
41954195
override_shutdown_script,
4196+
&self.logger,
41964197
)?;
41974198
failed_htlcs = htlcs;
41984199

@@ -11231,7 +11232,12 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1123111232
let (shutdown, monitor_update_opt, htlcs) = try_channel_entry!(
1123211233
self,
1123311234
peer_state,
11234-
chan.shutdown(&self.signer_provider, &peer_state.latest_features, &msg),
11235+
chan.shutdown(
11236+
&self.logger,
11237+
&self.signer_provider,
11238+
&peer_state.latest_features,
11239+
&msg
11240+
),
1123511241
chan_entry
1123611242
);
1123711243
dropped_htlcs = htlcs;

0 commit comments

Comments
 (0)