') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); Channel logging improvements by joostjager · Pull Request #4242 · lightningdevkit/rust-lightning · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lightning/src/ln/channel.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -8905,8 +8905,8 @@ where
);
return_with_htlcs_to_fail!(htlcs_to_fail);
} else {
log_debug!(logger, "Received a valid revoke_and_ack with no reply necessary. {} monitor update.",
release_state_str);
log_debug!(logger, "Received a valid revoke_and_ack with no reply necessary. {} monitor update {}.",
release_state_str, monitor_update.update_id);

self.monitor_updating_paused(
false,
Expand Down
114 changes: 75 additions & 39 deletions lightning/src/ln/channelmanager.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -9440,8 +9440,11 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
}
}

#[rustfmt::skip]
fn handle_monitor_update_completion_actions<I: IntoIterator<Item=MonitorUpdateCompletionAction>>(&self, actions: I) {
fn handle_monitor_update_completion_actions<
I: IntoIterator<Item = MonitorUpdateCompletionAction>,
>(
&self, actions: I,
) {
debug_assert_ne!(self.pending_events.held_by_thread(), LockHeldState::HeldByThread);
debug_assert_ne!(self.claimable_payments.held_by_thread(), LockHeldState::HeldByThread);
debug_assert_ne!(self.per_peer_state.held_by_thread(), LockHeldState::HeldByThread);
Expand All@@ -9450,44 +9453,67 @@ This indicates a bug inside LDK. Please report this error at https://github.com/

for action in actions.into_iter() {
match action {
MonitorUpdateCompletionAction::PaymentClaimed { payment_hash, pending_mpp_claim } => {
if let Some((counterparty_node_id, chan_id, claim_ptr)) = pending_mpp_claim {
MonitorUpdateCompletionAction::PaymentClaimed {
payment_hash,
pending_mpp_claim,
} => {
let (peer_id, chan_id) = pending_mpp_claim
.as_ref()
.map(|c| (Some(c.0), Some(c.1)))
.unwrap_or_default();
let logger =
WithContext::from(&self.logger, peer_id, chan_id, Some(payment_hash));
log_trace!(logger, "Handling PaymentClaimed monitor update completion action");

if let Some((cp_node_id, chan_id, claim_ptr)) = pending_mpp_claim {
let per_peer_state = self.per_peer_state.read().unwrap();
per_peer_state.get(&counterparty_node_id).map(|peer_state_mutex| {
per_peer_state.get(&cp_node_id).map(|peer_state_mutex| {
let mut peer_state = peer_state_mutex.lock().unwrap();
let blockers_entry = peer_state.actions_blocking_raa_monitor_updates.entry(chan_id);
let blockers_entry =
peer_state.actions_blocking_raa_monitor_updates.entry(chan_id);
if let btree_map::Entry::Occupied(mut blockers) = blockers_entry {
blockers.get_mut().retain(|blocker|
if let &RAAMonitorUpdateBlockingAction::ClaimedMPPPayment { pending_claim } = &blocker {
if *pending_claim == claim_ptr {
let mut pending_claim_state_lock = pending_claim.0.lock().unwrap();
let pending_claim_state = &mut *pending_claim_state_lock;
pending_claim_state.channels_without_preimage.retain(|(cp, cid)| {
let this_claim =
*cp == counterparty_node_id && *cid == chan_id;
if this_claim {
pending_claim_state.channels_with_preimage.push((*cp, *cid));
false
} else { true }
});
if pending_claim_state.channels_without_preimage.is_empty() {
for (cp, cid) in pending_claim_state.channels_with_preimage.iter() {
let freed_chan = (*cp, *cid, blocker.clone());
freed_channels.push(freed_chan);
}
}
!pending_claim_state.channels_without_preimage.is_empty()
} else { true }
} else { true }
);
blockers.get_mut().retain(|blocker| {
let pending_claim = match &blocker {
RAAMonitorUpdateBlockingAction::ClaimedMPPPayment {
pending_claim,
} => pending_claim,
_ => return true,
};
if *pending_claim != claim_ptr {
return true;
}
let mut claim_state_lock = pending_claim.0.lock().unwrap();
let claim_state = &mut *claim_state_lock;
claim_state.channels_without_preimage.retain(|(cp, cid)| {
let this_claim = *cp == cp_node_id && *cid == chan_id;
if this_claim {
claim_state.channels_with_preimage.push((*cp, *cid));
false
} else {
true
}
});
if claim_state.channels_without_preimage.is_empty() {
for (cp, cid) in claim_state.channels_with_preimage.iter() {
let freed_chan = (*cp, *cid, blocker.clone());
freed_channels.push(freed_chan);
}
}
!claim_state.channels_without_preimage.is_empty()
});
if blockers.get().is_empty() {
blockers.remove();
}
}
});
}

let payment = self.claimable_payments.lock().unwrap().pending_claiming_payments.remove(&payment_hash);
let payment = self
.claimable_payments
.lock()
.unwrap()
.pending_claiming_payments
.remove(&payment_hash);
if let Some(ClaimingPayment {
amount_msat,
payment_purpose: purpose,
Expand All@@ -9497,7 +9523,8 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
onion_fields,
payment_id,
durable_preimage_channel,
}) = payment {
}) = payment
{
let event = events::Event::PaymentClaimed {
payment_hash,
purpose,
Expand All@@ -9508,8 +9535,8 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
onion_fields,
payment_id,
};
let action = if let Some((outpoint, counterparty_node_id, channel_id))
= durable_preimage_channel
let action = if let Some((outpoint, counterparty_node_id, channel_id)) =
durable_preimage_channel
{
Some(EventCompletionAction::ReleaseRAAChannelMonitorUpdate {
channel_funding_outpoint: Some(outpoint),
Expand All@@ -9526,12 +9553,18 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
// `payment_id` should suffice to ensure we never spuriously drop a second
// event for a duplicate payment.
if !pending_events.contains(&event_action) {
log_trace!(
logger,
"Queuing PaymentClaimed event with event completion action {:?}",
event_action.1
);
pending_events.push_back(event_action);
}
}
},
MonitorUpdateCompletionAction::EmitEventAndFreeOtherChannel {
event, downstream_counterparty_and_funding_outpoint
event,
downstream_counterparty_and_funding_outpoint,
} => {
self.pending_events.lock().unwrap().push_back((event, None));
if let Some(unblocked) = downstream_counterparty_and_funding_outpoint {
Expand All@@ -9543,7 +9576,9 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
}
},
MonitorUpdateCompletionAction::FreeOtherChannelImmediately {
downstream_counterparty_node_id, downstream_channel_id, blocking_action,
downstream_counterparty_node_id,
downstream_channel_id,
blocking_action,
} => {
self.handle_monitor_update_release(
downstream_counterparty_node_id,
Expand DownExpand Up@@ -17109,17 +17144,18 @@ where

let logger = WithChannelMonitor::from(&args.logger, monitor, None);
let channel_id = monitor.channel_id();
log_info!(
logger,
"Queueing monitor update to ensure missing channel is force closed",
);
let monitor_update = ChannelMonitorUpdate {
update_id: monitor.get_latest_update_id().saturating_add(1),
updates: vec![ChannelMonitorUpdateStep::ChannelForceClosed {
should_broadcast: true,
}],
channel_id: Some(monitor.channel_id()),
};
log_info!(
logger,
"Queueing monitor update {} to ensure missing channel is force closed",
monitor_update.update_id
);
let funding_txo = monitor.get_funding_txo();
let update = BackgroundEvent::MonitorUpdateRegeneratedOnStartup {
counterparty_node_id,
Expand Down
Loading