Skip to content

Commit 16deda0

Browse files
committed
Allow manually passing a timestamp to channel_failed. Fixes #1914.
1 parent e9d4ae1 commit 16deda0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lightning/src/routing/gossip.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,14 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
15411541
#[cfg(not(feature = "std"))]
15421542
let current_time_unix = None;
15431543

1544+
self.channel_failed_with_time(short_channel_id, is_permanent, current_time_unix)
1545+
}
1546+
1547+
/// Marks a channel in the graph as failed if a corresponding HTLC fail was sent.
1548+
/// If permanent, removes a channel from the local storage.
1549+
/// May cause the removal of nodes too, if this was their last channel.
1550+
/// If not permanent, makes channels unavailable for routing.
1551+
fn channel_failed_with_time(&self, short_channel_id: u64, is_permanent: bool, current_time_unix: Option<u64>) {
15441552
let mut channels = self.channels.write().unwrap();
15451553
if is_permanent {
15461554
if let Some(chan) = channels.remove(&short_channel_id) {
@@ -2537,7 +2545,7 @@ mod tests {
25372545

25382546
// Mark the channel as permanently failed. This will also remove the two nodes
25392547
// and all of the entries will be tracked as removed.
2540-
network_graph.channel_failed(short_channel_id, true);
2548+
network_graph.channel_failed_with_time(short_channel_id, true, Some(tracking_time));
25412549

25422550
// Should not remove from tracking if insufficient time has passed
25432551
network_graph.remove_stale_channels_and_tracking_with_time(

0 commit comments

Comments
 (0)