Skip to content

Commit c662dd3

Browse files
committed
Fix XXXs that slipped into router and handle HTLCFailCHannelUpdates
1 parent 3bcd911 commit c662dd3

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/ln/router.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -349,18 +349,25 @@ impl RoutingMessageHandler for Router {
349349
&msgs::HTLCFailChannelUpdate::ChannelUpdateMessage { ref msg } => {
350350
let _ = self.handle_channel_update(msg);
351351
},
352-
&msgs::HTLCFailChannelUpdate::ChannelClosed { ref short_channel_id, is_permanent:_ } => {
353-
//XXX
352+
&msgs::HTLCFailChannelUpdate::ChannelClosed { ref short_channel_id, ref is_permanent } => {
354353
let mut network = self.network_map.write().unwrap();
355-
if let Some(chan) = network.channels.remove(short_channel_id) {
356-
Self::remove_channel_in_nodes(&mut network.nodes, &chan, *short_channel_id);
354+
if *is_permanent {
355+
if let Some(chan) = network.channels.remove(short_channel_id) {
356+
Self::remove_channel_in_nodes(&mut network.nodes, &chan, *short_channel_id);
357+
}
358+
} else {
359+
if let Some(chan) = network.channels.get_mut(short_channel_id) {
360+
chan.one_to_two.enabled = false;
361+
chan.two_to_one.enabled = false;
362+
}
357363
}
358364
},
359-
&msgs::HTLCFailChannelUpdate::NodeFailure { ref node_id, is_permanent:_ } => {
360-
//XXX
361-
//let mut network = self.network_map.write().unwrap();
362-
//TODO: check _blamed_upstream_node
363-
self.mark_node_bad(node_id, false);
365+
&msgs::HTLCFailChannelUpdate::NodeFailure { ref node_id, ref is_permanent } => {
366+
if *is_permanent {
367+
//TODO: Wholly remove the node
368+
} else {
369+
self.mark_node_bad(node_id, false);
370+
}
364371
},
365372
}
366373
}

0 commit comments

Comments
 (0)