@@ -1541,6 +1541,14 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
1541
1541
#[ cfg( not( feature = "std" ) ) ]
1542
1542
let current_time_unix = None ;
1543
1543
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 > ) {
1544
1552
let mut channels = self . channels . write ( ) . unwrap ( ) ;
1545
1553
if is_permanent {
1546
1554
if let Some ( chan) = channels. remove ( & short_channel_id) {
@@ -2537,18 +2545,18 @@ mod tests {
2537
2545
2538
2546
// Mark the channel as permanently failed. This will also remove the two nodes
2539
2547
// 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 ) ) ;
2541
2549
2542
2550
// Should not remove from tracking if insufficient time has passed
2543
2551
network_graph. remove_stale_channels_and_tracking_with_time (
2544
2552
tracking_time + REMOVED_ENTRIES_TRACKING_AGE_LIMIT_SECS - 1 ) ;
2545
- assert_eq ! ( network_graph. removed_channels. lock( ) . unwrap( ) . len( ) , 1 ) ;
2553
+ assert_eq ! ( network_graph. removed_channels. lock( ) . unwrap( ) . len( ) , 1 , "Removed channel count ≠ 1 with tracking_time {}" , tracking_time ) ;
2546
2554
2547
2555
// Provide a later time so that sufficient time has passed
2548
2556
network_graph. remove_stale_channels_and_tracking_with_time (
2549
2557
tracking_time + REMOVED_ENTRIES_TRACKING_AGE_LIMIT_SECS ) ;
2550
- assert ! ( network_graph. removed_channels. lock( ) . unwrap( ) . is_empty( ) ) ;
2551
- assert ! ( network_graph. removed_nodes. lock( ) . unwrap( ) . is_empty( ) ) ;
2558
+ assert ! ( network_graph. removed_channels. lock( ) . unwrap( ) . is_empty( ) , "Unexpectedly removed channels with tracking_time {}" , tracking_time ) ;
2559
+ assert ! ( network_graph. removed_nodes. lock( ) . unwrap( ) . is_empty( ) , "Unexpectedly removed nodes with tracking_time {}" , tracking_time ) ;
2552
2560
}
2553
2561
2554
2562
#[ cfg( not( feature = "std" ) ) ]
0 commit comments