X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=lightning%2Fsrc%2Frouting%2Fgossip.rs;h=d31d08f5ffb9c72466cc8825472109d1f8849b19;hb=1e81287cbcb3cbe83557b6b092fa263016f0d28d;hp=d90e4c437939d588beba4b209fc6e4bdc9e11a90;hpb=e9d4ae1d3ea3ccfad4ea5ab209d733d54e06ed93;p=rust-lightning diff --git a/lightning/src/routing/gossip.rs b/lightning/src/routing/gossip.rs index d90e4c43..d31d08f5 100644 --- a/lightning/src/routing/gossip.rs +++ b/lightning/src/routing/gossip.rs @@ -1541,6 +1541,14 @@ impl NetworkGraph where L::Target: Logger { #[cfg(not(feature = "std"))] let current_time_unix = None; + self.channel_failed_with_time(short_channel_id, is_permanent, current_time_unix) + } + + /// Marks a channel in the graph as failed if a corresponding HTLC fail was sent. + /// If permanent, removes a channel from the local storage. + /// May cause the removal of nodes too, if this was their last channel. + /// If not permanent, makes channels unavailable for routing. + fn channel_failed_with_time(&self, short_channel_id: u64, is_permanent: bool, current_time_unix: Option) { let mut channels = self.channels.write().unwrap(); if is_permanent { if let Some(chan) = channels.remove(&short_channel_id) { @@ -2537,7 +2545,7 @@ mod tests { // Mark the channel as permanently failed. This will also remove the two nodes // and all of the entries will be tracked as removed. - network_graph.channel_failed(short_channel_id, true); + network_graph.channel_failed_with_time(short_channel_id, true, Some(tracking_time)); // Should not remove from tracking if insufficient time has passed network_graph.remove_stale_channels_and_tracking_with_time(