@@ -352,9 +352,10 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
352
352
let _ = self . update_channel ( msg) ;
353
353
} ,
354
354
NetworkUpdate :: ChannelFailure { short_channel_id, is_permanent } => {
355
- let action = if is_permanent { "Removing" } else { "Not touching" } ;
356
- log_debug ! ( self . logger, "{} channel graph entry for {} due to a payment failure." , action, short_channel_id) ;
357
- self . channel_failed ( short_channel_id, is_permanent) ;
355
+ if is_permanent {
356
+ log_debug ! ( self . logger, "Removing channel graph entry for {} due to a payment failure." , short_channel_id) ;
357
+ self . channel_failed_permanent ( short_channel_id) ;
358
+ }
358
359
} ,
359
360
NetworkUpdate :: NodeFailure { ref node_id, is_permanent } => {
360
361
if is_permanent {
@@ -1632,37 +1633,27 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
1632
1633
Ok ( ( ) )
1633
1634
}
1634
1635
1635
- /// Marks a channel in the graph as failed if a corresponding HTLC fail was sent.
1636
- ///
1637
- /// If permanent, removes a channel from the local storage.
1638
- /// May cause the removal of nodes too, if this was their last channel.
1636
+ /// Marks a channel in the graph as failed permanently.
1639
1637
///
1640
- /// If not permanent, no action is taken as such a failure likely indicates the node simply
1641
- /// lacked liquidity and your scorer should handle this instead.
1642
- pub fn channel_failed ( & self , short_channel_id : u64 , is_permanent : bool ) {
1638
+ /// The channel and any node for which this was their last channel are removed from the graph.
1639
+ pub fn channel_failed_permanent ( & self , short_channel_id : u64 ) {
1643
1640
#[ cfg( feature = "std" ) ]
1644
1641
let current_time_unix = Some ( SystemTime :: now ( ) . duration_since ( UNIX_EPOCH ) . expect ( "Time must be > 1970" ) . as_secs ( ) ) ;
1645
1642
#[ cfg( not( feature = "std" ) ) ]
1646
1643
let current_time_unix = None ;
1647
1644
1648
- self . channel_failed_with_time ( short_channel_id, is_permanent , current_time_unix)
1645
+ self . channel_failed_permanent_with_time ( short_channel_id, current_time_unix)
1649
1646
}
1650
1647
1651
- /// Marks a channel in the graph as failed if a corresponding HTLC fail was sent .
1648
+ /// Marks a channel in the graph as failed permanently .
1652
1649
///
1653
- /// If permanent, removes a channel from the local storage.
1654
- /// May cause the removal of nodes too, if this was their last channel.
1655
- ///
1656
- /// If not permanent, no action is taken as such a failure likely indicates the node simply
1657
- /// lacked liquidity and your scorer should handle this instead.
1658
- fn channel_failed_with_time ( & self , short_channel_id : u64 , is_permanent : bool , current_time_unix : Option < u64 > ) {
1650
+ /// The channel and any node for which this was their last channel are removed from the graph.
1651
+ fn channel_failed_permanent_with_time ( & self , short_channel_id : u64 , current_time_unix : Option < u64 > ) {
1659
1652
let mut channels = self . channels . write ( ) . unwrap ( ) ;
1660
- if is_permanent {
1661
- if let Some ( chan) = channels. remove ( & short_channel_id) {
1662
- let mut nodes = self . nodes . write ( ) . unwrap ( ) ;
1663
- self . removed_channels . lock ( ) . unwrap ( ) . insert ( short_channel_id, current_time_unix) ;
1664
- Self :: remove_channel_in_nodes ( & mut nodes, & chan, short_channel_id) ;
1665
- }
1653
+ if let Some ( chan) = channels. remove ( & short_channel_id) {
1654
+ let mut nodes = self . nodes . write ( ) . unwrap ( ) ;
1655
+ self . removed_channels . lock ( ) . unwrap ( ) . insert ( short_channel_id, current_time_unix) ;
1656
+ Self :: remove_channel_in_nodes ( & mut nodes, & chan, short_channel_id) ;
1666
1657
}
1667
1658
}
1668
1659
@@ -2598,7 +2589,7 @@ pub(crate) mod tests {
2598
2589
2599
2590
// Mark the channel as permanently failed. This will also remove the two nodes
2600
2591
// and all of the entries will be tracked as removed.
2601
- network_graph. channel_failed_with_time ( short_channel_id, true , Some ( tracking_time) ) ;
2592
+ network_graph. channel_failed_permanent_with_time ( short_channel_id, Some ( tracking_time) ) ;
2602
2593
2603
2594
// Should not remove from tracking if insufficient time has passed
2604
2595
network_graph. remove_stale_channels_and_tracking_with_time (
0 commit comments