Skip to content

Commit f5ff5d1

Browse files
authored
Merge pull request #220 from TheBlueMatt/2018-10-oops-xxx
Fix XXXs that slipped into router and handle HTLCFailCHannelUpdates
2 parents 3bcd911 + fc8cd9f commit f5ff5d1

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ rust:
33
- stable
44
- beta
55
- 1.22.0
6+
- 1.29.2
67
cache: cargo
78

89
before_install:
@@ -12,4 +13,4 @@ before_install:
1213
script:
1314
- cargo build --verbose
1415
- cargo test --verbose
15-
- if [ "$(rustup show | grep default | grep stable)" != "" ]; then cd fuzz && cargo test --verbose && ./travis-fuzz.sh; fi
16+
- if [ "$(rustup show | grep default | grep 1.29.2)" != "" ]; then cd fuzz && cargo test --verbose && ./travis-fuzz.sh; fi

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)